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

增加 silence 方式 #12

Open
hustcc opened this issue Feb 4, 2024 · 0 comments
Open

增加 silence 方式 #12

hustcc opened this issue Feb 4, 2024 · 0 comments

Comments

@hustcc
Copy link
Member

hustcc commented Feb 4, 2024

[中级任务]

参考 batch 的方式,batch 是批量处理多个数据 API,只抛出一次 changes;silence 是处理数据后不抛出任何的 changes,两者都是对性能进行优化。

batch

Batch several graph changes into one. Make several changes, but dispatch only one ChangedEvent at the end of batch:

graph.batch(() => {
  graph.addNodes([]);
  graph.addEdges([]);
});

silence

DO NOT dispatch any changes.

graph.silence(() => {
  graph.addNodes([]);
  graph.addEdges([]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants