You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.
construne=observableToRune(newObservable((observer)=>{observer.next("hello")observer.next("there!")observer.next("how are you?")}),)construnTest=async(id: string)=>{forawait(constvalueofrune.iter()){console.log(`${value} from ${id}`)}}Promise.all([runTest("a"),runTest("b")])
outputs this:
how are you? from a
how are you? from b
As you can see: it has skipped the first 2 emitted values.
Also, I've noticed that the program exited before the Observable completed 🤔 I'm not quite sure if this is a bug or not, TBH... However, if it's not, then I think that it's a behavior worth being documented.
On the other hand, the following code:
classObservableErrorextendsError{overridereadonlyname="ObservableError"constructor(publicvalue: unknown){super()}}construne=observableToRune(newObservable((observer)=>{setTimeout(()=>{observer.next("hello")observer.next("there!")observer.next("how are you?")},0)}),)construnTest=async(id: string)=>{forawait(constvalueofrune.iter()){console.log(`${value} from ${id}`)}}Promise.all([runTest("a"),runTest("b")])
outputs this:
hello from a
hello from b
there! from a
there! from b
how are you? from a
how are you? from b
I know that you may consider this a feature 🤷♂️. However, please understand that from my point of view: this is an arbitrary baked-in behavior and it would make my life hell if I had to use Runes. The expected output should have been:
hello from a
there! from a
how are you? from a
hello from b
there! from b
how are you? from b
The text was updated successfully, but these errors were encountered:
As you can see: it has skipped the first 2 emitted values.
This is a bug; thanks for catching it. I've opened a PR to resolve this: #1160.
Also, I've noticed that the program exited before the Observable completed 🤔
This is independent of Rune. The program exits when the event queue is empty, even if there are unresolved promises. Because nothing in the code creates a task to call .complete(), the program is not held open for this. Removing Rune from the equation, the following adaption of your example also exits:
newPromise<void>((resolve)=>{newObservable((observer)=>{observer.next("hello")observer.next("there!")observer.next("how are you?")}).subscribe({next: console.log,error: console.error,complete: resolve,})}).then(()=>{console.log("done")})
@tjjfvi I'm re-opening this bug because I haven't been able to understand the reason why the following code:
classObservableErrorextendsError{overridereadonlyname="ObservableError"constructor(publicvalue: unknown){super()}}construne=observableToRune(newObservable((observer)=>{setTimeout(()=>{observer.next("hello")observer.next("there!")observer.next("how are you?")},0)}),)construnTest=async(id: string)=>{forawait(constvalueofrune.iter()){console.log(`${value} from ${id}`)}}Promise.all([runTest("a"),runTest("b")])
outputs this:
hello from a
hello from b
there! from a
there! from b
how are you? from a
how are you? from b
rather than outputting this:
hello from a
there! from a
how are you? from a
hello from b
there! from b
how are you? from b
Could you please justify why that is not a bug, and in the event that this is not considered a bug, whether there is a way to opt-out from such an awkward behavior? 🙏
Following the recipe outlined in here.
The following code:
outputs this:
As you can see: it has skipped the first 2 emitted values.
Also, I've noticed that the program exited before the Observable completed 🤔 I'm not quite sure if this is a bug or not, TBH... However, if it's not, then I think that it's a behavior worth being documented.
On the other hand, the following code:
outputs this:
I know that you may consider this a feature 🤷♂️. However, please understand that from my point of view: this is an arbitrary baked-in behavior and it would make my life hell if I had to use Runes. The expected output should have been:
The text was updated successfully, but these errors were encountered: