Releases: ArthurClemens/use-stream
Releases · ArthurClemens/use-stream
0.4.3
v0.4.0
Breaking change
When using defer: true
, useStream()
no longer returns null
when the model is not yet initialized. To maintain a consistent return type, useStream()
now returns the input model plus extra attribute isDeferred
(which will be true
at the first run, when using defer
).
Previous code:
const model = useStream({
model: () => ({ // first optimization: model function
index: stream(0),
count: stream(3)
}),
defer: true, // second optimization
})
if (!model) {
// first render
return null
}
const { index, count } = model
Current code:
const model = useStream({
model: () => ({ // first optimization: model function
index: stream(0),
count: stream(3)
}),
defer: true, // second optimization
})
const { index, count, isDeferred } = model
if (isDeferred) {
// first render
return null
}