kukeiko / entity-space

MIT License
5 stars 1 forks source link

implement reactive queries #180

Closed kukeiko closed 2 years ago

kukeiko commented 2 years ago

What

Reactive queries - when a user issues a query, they can somehow mark them as being reactive. If marked that way, query should emit if any changes to its result have been made.

Example:

Why

Because:

Notes

need some form of protection against cyclic dependencies between reactive queries resulting in the browser crashing. for example, if we use this lib for state management, if we make changes to the stored entities based on the result of another query, that other query might trigger again, resulting in an endless loop.

kukeiko commented 2 years ago

an extremely basic and primitive form of reactive queries is implemented in the workspace. can't really stay the way it works now: on each change to the cached data, every reactive query is re-emitted, and a distinctUntilChanged() (with a custom comparator) is used to prevent endless loops