Skip to content

Producer clean-up / or unmount lifecycle method #60

@dumconstantin

Description

@dumconstantin

For async producers a clean-up mechanism is needed in order to free up memory or ensure that certain effects to not occur as the initiator does no longer exist.

The simplest way to implement this is using a return statement with a function that will be called by the engine when the producer will be unmounted:

const producer: Producer = ({ stream = streamAPI, value = Update.value }) => {
  const instance = stream.create({ }).on(x => {
    value.set(x)
  })
  return () => instance.end()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions