a signal context class is required to create and register signals. without it, signals won't be able to communicate with each other, and it would not be possible to build a signals dependency graph.

Example

const ctx = new Context() // create signal context
const createState = ctx.addClass(StateSignal_Factory) // feed the state signal factory function to get a signal generator
const createMemo = ctx.addClass(MemoSignal_Factory) // feed the memo signal factory function to get a signal generator

const [idNum, getNum, setNum] = createState<number>(0)
const [idNum2, getNum2] = createMemo((memo_id) => {
const num2 = getNum(memo_id) ** 2
console.log("recomputing number squared:", num2)
return num2
}, { defer: false })

setNum(2) // console.log: "recomputing number squared: 4"
setNum(4) // console.log: "recomputing number squared: 16"

Constructors

Properties

addEdge: ((src_id, dst_id) => boolean)

Type declaration

    • (src_id, dst_id): boolean
    • Parameters

      • src_id: number
      • dst_id: number

      Returns boolean

delEdge: ((src_id, dst_id) => boolean)

Type declaration

    • (src_id, dst_id): boolean
    • Parameters

      • src_id: number
      • dst_id: number

      Returns boolean

newId: (() => number)

Type declaration

    • (): number
    • Returns number

getId: ((id) => undefined | Signal<any>)

Type declaration

    • (id): undefined | Signal<any>
    • Parameters

      • id: number

      Returns undefined | Signal<any>

setId: ((id, signal) => void)

Type declaration

    • (id, signal): void
    • Parameters

      Returns void

delId: ((id) => boolean)

Type declaration

    • (id): boolean
    • Parameters

      • id: number

      Returns boolean

runId: ((id) => boolean)

Type declaration

    • (id): boolean
    • Parameters

      • id: number

      Returns boolean

swapId: ((id1, id2) => void)

Type declaration

    • (id1, id2): void
    • Parameters

      • id1: number
      • id2: number

      Returns void

onInit: (<T>(id, initialization_func) => undefined | T)

Type declaration

    • <T>(id, initialization_func): undefined | T
    • Type Parameters

      • T

      Parameters

      • id: number
      • initialization_func: (() => T)
          • (): T
          • Returns T

      Returns undefined | T

onDelete: ((id, cleanup_func) => void)

Type declaration

    • (id, cleanup_func): void
    • Parameters

      • id: number
      • cleanup_func: (() => void)
          • (): void
          • Returns void

      Returns void

clearCache: (() => void)

Type declaration

    • (): void
    • Returns void

addClass: (<SIGNAL_CLASS>(factory_fn) => SIGNAL_CLASS["create"])

Type declaration

getClass: (<SIGNAL_CLASS>(factory_fn) => SIGNAL_CLASS)

Type declaration

Generated using TypeDoc