Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: change detection mechanism refactor #51

Merged
merged 1 commit into from
May 29, 2019
Merged

Conversation

smalluban
Copy link
Contributor

@smalluban smalluban commented May 29, 2019

Change detection mechanism relays on DOM events. This has two significant drawbacks:

  • We can only attach cache mechanism to objects that are HTML elements
  • DOM events API is slow and complicates observing children factory due to listening bubbling event

This PR introduces a new change detection mechanism:

  • It's based on internal emitter
  • Allows observing changes in other properties like it was implemented in render factory (scheduler)
  • Decauples cache from HTML elements - allows creating store factory with objects related to HTML elements with a proper cache mechanism connected between them

From now, instead of using @invalidate event, you have to use the observe method of the descriptor:

MyElement = {
  property: {
    get(host, lastValue) {...},
    set(host, value) {...},
    observe(host, value, lastValue) {
       // call side effects here when property value changes
    },
};

Breaking Changes

  • Use observe method instead of addEventListener('@invaldiate', ...)

@coveralls
Copy link

coveralls commented May 29, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling d88e040 on observer-refactor into 0a3e279 on master.

@smalluban smalluban force-pushed the observer-refactor branch 8 times, most recently from 9c37081 to cf8e409 Compare May 29, 2019 14:17
BREAKING CHANGE: Change detection mechanism no longer dispatch `@invalidate` DOM event. Use introduced `observe` method of the property descriptor. Read more in descriptors section of the documentation.
@smalluban smalluban force-pushed the observer-refactor branch from cf8e409 to d88e040 Compare May 29, 2019 17:22
@smalluban smalluban merged commit d8f7365 into master May 29, 2019
@smalluban smalluban deleted the observer-refactor branch July 27, 2019 10:55
@smalluban smalluban restored the observer-refactor branch July 27, 2019 10:55
@smalluban smalluban deleted the observer-refactor branch July 27, 2019 10:56
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants