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

Time.every has incorrect or at least unintuitive behaviour #25

Open
jjant opened this issue Mar 11, 2020 · 0 comments
Open

Time.every has incorrect or at least unintuitive behaviour #25

jjant opened this issue Mar 11, 2020 · 0 comments

Comments

@jjant
Copy link

jjant commented Mar 11, 2020

Description:

In short, Time.every has a very different behaviour than setInterval, subscriptions to an equal amount of time (i.e, the first argument of the function) get bundled together instead of getting treated as separate subscriptions, with different start times. This creates a very weird behaviour exemplified below.

Example: https://ellie-app.com/8h5QfbhS6Dka1

In this example we have two 5 second subscriptions to Time.every. One is created on init, the second is created after 3 seconds have passed. The expected behaviour would be that at the 5 second mark, only the first message gets triggered, and at the 8 second mark, the second one is.

Why this is weird:

The above behaviour could be considered ok, but it means that we get strange interactions, in the above example, if we change the second 5-second subscription to use a 4.999s rate, we get the expected behaviour (one that works like setInterval).

Example of this second case here: https://ellie-app.com/8h5VgDkD7PMa1

Problems and possible solution:
I don't think that this problem can be fixed with the current API, it looks like we'd need to add a key or something to Time.every to identify different calls to the subscription with the same period.

If we do, fixing this should be simple enough, instead of just using the period as the key in the manager's state, we could use the pair (stringKey, period) or something.

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