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

提供页面之间的交互 #18

Open
oott123 opened this issue Sep 3, 2018 · 4 comments
Open

提供页面之间的交互 #18

oott123 opened this issue Sep 3, 2018 · 4 comments

Comments

@oott123
Copy link
Contributor

oott123 commented Sep 3, 2018

在 ralltiir (尤其是新的实例化 service)中,尽管我们并不希望如此,但经常遇到需要两个页面之间传递数据的情况。例如,页面调起“登录”页面,需要将登录的结果传递回上一个页面;在 A 页面预先获取 B 页面的数据,需要将数据传递给下一个页面;需要广播数据到各个页面使他们刷新状态等。

历史上,这些事情都使用了在 window 上挂载全局事件 / 变量的折衷方案解决。然而,随着 ralltiir 和客户端浏览器的紧密结合,前后两个页面并不一定共用 window,因而这个方法会遭遇新的问题。

基于此,ralltiir 应当提供一种前后页面通信的方法。主要应包括两种:

  1. 类似 Android 的 startActivityForResult 的,action.redirect 方法可以在其打开的新页面退场时得到通知和返回参数
  2. 在任意页面都能通过“广播”通知所有 service (和 service 实例)以处理自己关注的消息

诸如登录的需求,应当使用前者来达成;其余不能使用前者来达成通信的任务,使用后者来达成。

@oott123
Copy link
Contributor Author

oott123 commented Sep 3, 2018

@harttle

@harttle
Copy link
Contributor

harttle commented Sep 3, 2018

Shared Worker 可能可以满足需求,比端直接支持要标准。听说Worker兼容性不错,需要调研。

@xueran
Copy link
Contributor

xueran commented Sep 5, 2018

9.5沟通结论:由于端上多webview机制,A页面切换到B页面,A页面就不存在了,所以通信机制没意义,最终结论:通信机制不依赖端,基于H5的localstorage change事件来实现

@oott123
Copy link
Contributor Author

oott123 commented Sep 6, 2018

Shared Worker 可能可以满足需求,比端直接支持要标准。听说Worker兼容性不错,需要调研。

@harttle Worker 兼容性是不错,可是 Shared Worker 简直一言难尽。。

@xueran xueran added the hold label Sep 28, 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

3 participants