Skip to content

Releases: ArthurClemens/use-stream

0.4.3

03 Mar 09:59
Compare
Choose a tag to compare

Maintenance release.

v0.4.0

18 Apr 10:48
Compare
Choose a tag to compare

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
}