question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question about onStart execution order

See original GitHub issue

In the following example I was expecting “onStart” callback to be invoked first, but noticed it was run last:

https://codepen.io/ejez/pen/NWjWBoJ

const src = fromArray([0, 1]);

const { unsubscribe } = pipe(
  src,

  onStart(() => console.log("onStart...")),

  onPush(() => console.log("onPush...")),

  onEnd(() => console.log("onEnd...")),

  subscribe((result) => console.log(result))
);

result:

"onPush..."
0
"onPush..."
1
"onEnd..."
"onStart..."

From the docs:

When the stream starts then the sink is called with Start, Then for every incoming, new value it’s called with Push('a), and when the stream ends it’s finally called with End.

onStart Run a callback when the Start signal is sent to the sink by the source.

Many thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ejezcommented, Jun 30, 2021

Thanks!

What i did, is adding a condition for setting fetching to true in onSart (only when there is no data, ie first fetch). I will change it as per your suggestion, as it seems onStart is not the natural place for setting the fetching state.

0reactions
kittencommented, Jun 30, 2021

yea, sounds good 👍 I’ll close this for now, since I think the question itself is addressed.

The problems here and ambition is basically always with synchronous streams. The synchronous support in Wonka allows us to apply some nice tricks in urql, but that does come with some caveats. Synchronous events are just very different from asynchronous as it’ll always deal with an exact order.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Execution order of OnActivityResult and OnResume
I'm finding it gets called before OnResume, and even before OnStart. My sample code is below, I'm breakpointing the relevant methods to see...
Read more >
Confused about execution order in .NET MAUI #8088 - GitHub
NET MAUI app. In my case, it was going to the OnAppearing() method of LoginPage because it's the first item in the Shell...
Read more >
App.StartScreen: a new declarative alternative to Navigate in ...
If App.OnStart contains a Navigate function call, even if it is in an If function and rarely called, we must complete execution of...
Read more >
Execution order of Trigger, Workflow and Process
Answer to your first question: 1. Update trigger runs before Process and if Process has field update, it again ...
Read more >
The activity lifecycle | Android Developers
Activity B's onCreate() , onStart() , and onResume() methods execute in sequence. (Activity B now has user focus.) Then, if Activity A is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found