Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ios][android] support return value for native module APIs someway #968

Closed
Jinjiang opened this issue Aug 10, 2016 · 5 comments
Closed

[ios][android] support return value for native module APIs someway #968

Jinjiang opened this issue Aug 10, 2016 · 5 comments

Comments

@Jinjiang
Copy link
Contributor

For example getItem(key) in storage module. It's more simple and familiar with web developers.
Of course from the perf aspect, this kind of API is suitable for non-frequent calls only.

@sospartan
Copy link
Contributor

It's a very very bad idea:
0. Break 'js-native' bridge.
0. Performance issue.
0. Nobody will like do IO operation in sync way.

@littleseven
Copy link
Contributor

Maybe we can refer to the design of JSON-RPC.
1)Notification. (no return)
2)Request and Response.

@MrRaindrop
Copy link
Member

MrRaindrop commented Aug 10, 2016

If this issue is solved, then the timer api module will be valid to use again.

var timer = require('@weex-module/timer')
var id = timer.setTimeout(function() { /*none*/ }, 1000)
timer.clearTimeout(id)

even though the timer can be set and clear by calling setTimeout/clearTimeout directly, still we like the require way because the consistency of using 'require' to require a API module.

And maybe there occurs another using case in another day. I think the ability should be prepared to solve such problems.

@Jinjiang
Copy link
Contributor Author

Jinjiang commented Aug 11, 2016

The more valuable thing of this is we provide module developers the ability of both mechanism for sync & async pattern. Neither keep all module APIs async nor switch all module APIs into sync mode. The module developers could make the choice on their own.

Take storage module for example, this is a very simple k-v pairs data storage, not necessary to implemented by a SQLite database and async/callback APIs. This could be more easily to implement and use.

Thanks.

@Jinjiang
Copy link
Contributor Author

This discussion is moved to #1677
Thanks.

MrRaindrop pushed a commit to MrRaindrop/weex that referenced this issue Apr 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants