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

feat(runtime): add watcher data source #721

Merged
merged 1 commit into from
Sep 7, 2023
Merged

feat(runtime): add watcher data source #721

merged 1 commit into from
Sep 7, 2023

Conversation

tanbowensg
Copy link
Collaborator

Add a watcher data source, to watch expression changes, and trigger events.
With this data source, developer don't have to add onChange event for every component's state. It is also very useful to complicated expression.

The usage is like:
截屏2023-08-30 下午4 44 22

Note that the exp property requires a string in expression format without {{}}. This is to prevent the exp being evaled when compiling template.

@MrWindlike
Copy link
Contributor

  1. I'm not sure if we need to provide a Watcher at runtime. Because when listening for state changes to do something, it is easier to use it incorrectly.
  2. Why not just pass in the expression and listen for changes in its value directly in Watcher, instead of compiling it in Watcher? Writing plain strings has no editor prompt and is error-prone
  3. Can it support watch multiple states?

@tanbowensg
Copy link
Collaborator Author

@MrWindlike I changed implementation. Now the component implementation get raw exp from component.properties, so that user can have editor prompt when entering exp.

@tanbowensg tanbowensg force-pushed the feat/watcher branch 2 times, most recently from 98c41b0 to 79aab55 Compare September 1, 2023 06:38
@tanbowensg tanbowensg merged commit a5c74b5 into develop Sep 7, 2023
2 checks passed
@tanbowensg tanbowensg deleted the feat/watcher branch September 7, 2023 01:57
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

Successfully merging this pull request may close these issues.

2 participants