enactjs / enact

An app development framework built atop React that’s easy to use, performant and customizable.
http://enactjs.com
Apache License 2.0
316 stars 31 forks source link

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

Open vJIYEv opened 4 months ago

vJIYEv commented 4 months ago

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 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 (jiye.kim@lge.com)

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 82.51%. Comparing base (67b7156) to head (75ab31c).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #3250 +/- ## ======================================== Coverage 82.51% 82.51% ======================================== Files 157 157 Lines 7245 7245 Branches 1917 1917 ======================================== Hits 5978 5978 Misses 995 995 Partials 272 272 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.