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

最佳实践 点赞(收藏等)状态的全局同步更新 | zyestin #1

Open
utterances-bot opened this issue Apr 10, 2024 · 1 comment

Comments

@utterances-bot
Copy link

最佳实践 点赞(收藏等)状态的全局同步更新 | zyestin

有这么一个常见的需求 在对某个帖子进行点赞后,该帖子所出现的各个地方,e.g.帖子列表(可能多处)、帖子详情(可能多个),点赞状态实时同步、数量加/减1同步。
iOS 方案 在iOS,我是在每个帖子 所对应的 Model(数据)对象里 监听通知,判断 帖子ID,ID匹配 则更新 点赞状态,以此达到操作点赞后 实时同步同一帖子的点赞状态,非常简单好使!
RN 方案 但RN里,数据是一个{id:xx, ...}这样的对象,是不支持像在iOS那样,在这样对象里 写监听通知的代码的。
于是,那就放到hooks去实现。
Q:那需要什么样的hooks呢? A

http://localhost:1313/zyestin/posts/rn/status-sync-global/

Copy link
Owner

zyestin commented Apr 10, 2024

welcome to zyestin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants