-
Notifications
You must be signed in to change notification settings - Fork 0
Randomness
Brandon Jordan edited this page Aug 14, 2024
·
13 revisions
randomInt(min, max)
Spark provides an RNG
class for random number generation using the same min and max.
new RNG(init, min, max);
const x = new RNG(0, 0, window.innerWidth);
x.new(); // Creates a new random value and returns it.
A RandomStore
is an extension of Store
and RNG
* (*just borrows the new()
method).
const randomY = new RandomStore(0,0,window.innerHeight);
// Subscribe to random value.
randomY.model(() => {
// ...
});
randomY.new(); // Subscriber gets a new random value based on min and max.