enact icon indicating copy to clipboard operation
enact copied to clipboard

WRQ-153: Add sendLS2Request to use LS2Request with a promise

Open vJIYEv opened this issue 8 months ago • 1 comments

Checklist

  • [x] I have read and understand the contribution guide
  • [x] A CHANGELOG entry is included
  • [ ] At least one test case is included for this feature or bug fix
  • [x] Documentation was added or is not needed
  • [ ] This is an API breaking change

Issue Resolved / Feature Added

webos/LS2Request provides a class for making LS2 service request. It would be better to support the developer to request LS2 request with a promise

Resolution

LS2Request.send is a method to request luna call to a webos app or service. So send method with promise is what developers need. To provide LS2Request.send as a promise, I add a new function: sendLS2Request sendLS2Request returns a promise which run LS2Request.send. This promise will be resolved when send successes, and will be rejected when send fails. So developers can use their own onSuccess and onFailure after the promise is resolved or rejected.

Additional Considerations

I tried to make a new function as a react custom hook where useEffect is combined with sendLS2Request so that developers can use it more easily. However, I couldn't because onSuccess and onFailure functions both should be given in a component and should be in useEffect hook. I think it's better for developers to choose use useEffect or not in a component case by case.

Links

WRQ-153

Comments

Enact-DCO-1.0-Signed-off-by: Jiye Kim ([email protected])

vJIYEv avatar Jul 04 '24 09:07 vJIYEv