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

reconsider to add an async observation flavor #45

Closed
gullerya opened this issue May 30, 2020 · 5 comments
Closed

reconsider to add an async observation flavor #45

gullerya opened this issue May 30, 2020 · 5 comments
Assignees
Milestone

Comments

@gullerya
Copy link
Owner

Should it be possible to specify an async callbacks flavor?
If yes, shall I leverage an EventTarget object?

@gullerya gullerya added this to the 3.0 milestone May 30, 2020
@gullerya gullerya self-assigned this May 30, 2020
@gullerya
Copy link
Owner Author

I'm closing this again, I'll state few things to get to it back if needed in the future:

  • it is not really any async unless got for some setTimeout stuff and probably even more relevant - requestAnimationFrame; but as soon as things become that complex - my feeling is that it should be kept consuming application concern; at the end of the day we are already running in some callback context, so it might quite be good enough to just run as fast as possible, synchronously and if any needed - use another streaming patterns to batch / async heavy processing
  • no real use case so far seen for this scenario

@gullerya gullerya reopened this Aug 27, 2020
@gullerya
Copy link
Owner Author

Reopening this to link to another issue, that actually will benefit from this one. So this is a use-case that justifies and async flavor.

@gullerya
Copy link
Owner Author

As it can be seen, the async behaviour, while not yet justified in itself, may serve the expected API behaviour like an Object.assign flow. In that use-case, while the native behaviour is to perform each and every property assignment on it's own, thus causing the changes delivery one per callback, the expected Observable API behaviour is to get the changes in batch. Async management of the changes delivery is enabler for that step.

@gullerya
Copy link
Owner Author

Design decision made thus far:

  • async/sync changes delivery will be controllable on the level of Observable, nor lower than that (not per observer callback), nether higher - the whole framework
  • the default flavour will remain the same - sync
  • in order to make an Observable to dispatch the changes in async way the following API should be used (pay attention to the second options parameter):
    const oo = Observable.from({ <some object> }, { async: true });
  • changes will be delayed later on in the same task, by queueMicrotask means
  • if the callback causes new changes to be delivered, they'll be dispatched in the next microtask, not the currently running

@gullerya
Copy link
Owner Author

gullerya commented Sep 3, 2020

implemented in 3.2.0

@gullerya gullerya closed this as completed Sep 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant