WRQ-153: Add sendLS2Request to use LS2Request with a promise #3250
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
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 runLS2Request.send
.This promise will be resolved when
send
successes, and will be rejected whensend
fails.So developers can use their own
onSuccess
andonFailure
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 withsendLS2Request
so that developers can use it more easily.However, I couldn't because
onSuccess
andonFailure
functions both should be given in a component and should be inuseEffect
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])