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

Caching view function #30

Open
raimohanska opened this issue Oct 26, 2020 · 0 comments
Open

Caching view function #30

raimohanska opened this issue Oct 26, 2020 · 0 comments

Comments

@raimohanska
Copy link
Owner

Map/view functions in Observable libraries do not guarantee running the mapping function only on actual input changes.

The issue is illustrated in the Lonna tests: https://github.com/raimohanska/lonna/blob/master/src/view.test.ts#L63

Guaranteeing a minimal number of calls to the function would be very useful in Harmaja, where the functions create actual DOM nodes. It's worth noticing that the components are activated only once, but still, creation of DOM nodes is not something to do just for fun.

Ways to solve this:

  • Introduce a Harmaja.view function that caches values (in componentScope?) to avoid creating garbage
  • Investigate whether Lonna can be optimized to avoid these calls without sacrificing other good qualities. This may not be generally possible because delegating get() to parent observables is generally a good design because it guarantees freshness
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

1 participant