-
Notifications
You must be signed in to change notification settings - Fork 8
radioactive.react
The radioactive.react() loop is Radioactive's workhorse. You will find yourself creating tons of loops. And, in some cases, loops within loops.
In its most basic form, a loop runs from top to bottom. It will then wait for a change notification. At that moment, it will run again.
Sometimes, however, a loop will stop at an intermediate point. Before reaching the end of the block of code. This will happen whenever Radioactive is waiting from data to arrive from an async datasource.
You may be wondering whether keeping all these loops alive is expensive. The answer is: it depends.
- Any normal application should not need more than a few hundred of these loops to be alive at any given point in time.
- The problem is that is is sometimes hard to keep track of when they are created, and when they are destroyed
As someone once said:
Premature optimization is the root of all Evil. - Donald Knuth
But if you do need to optimize, then it is useful to understand what's going on.
Loops are implicitly created in a hierarchy. If you create a loop from a block of code that is executing within another loop, then the outer loop will automatically become the inner loop's parent.
This hierarchy, along with some assumptions and heuristics, give us a simple way of limiting the lifespan of a loop.
- Radioactive Tutorial
- API
- working with data
- publishing datasources
- utility
- Typescript Definition