Function dise

Attach side effect function to state within diInit callback

Effect can be Promise returned function

Value of resolved Promise will be passed to state function

Also variadic amount of state functions can passed as inputs Effect

const userId = dic<number>()
const user = dic<{age: number; id: number; name: string;}>()
const fetchUser = dise(
id => db.query('select * from users where id = $1', [id]),
user,
userId)

userId(1)
await fetchUser()
user() // {age: 50, id: 1, name: 'Bob'}
  • Type Parameters

    • R

    Parameters

    • effect: (() => Promise<R>)
        • (): Promise<R>
        • Returns Promise<R>

    • dicOutput: ((x: R) => R)
        • (x): R
        • Parameters

          Returns R

    Returns (() => Promise<R>) & {
        raw: (() => Promise<R>);
    }

  • Type Parameters

    • R
    • T1

    Parameters

    • effect: ((x1: T1) => Promise<R>)
        • (x1): Promise<R>
        • Parameters

          Returns Promise<R>

    • dicOutput: ((x: R) => R)
        • (x): R
        • Parameters

          Returns R

    • dicInput1: (() => T1)

    Returns (() => Promise<R>) & {
        raw: ((x1: T1) => Promise<R>);
    }

  • Type Parameters

    • R
    • I
    • T1
    • T2

    Parameters

    • effect: ((x1: T1, x2: T2) => Promise<R>)
        • (x1, x2): Promise<R>
        • Parameters

          Returns Promise<R>

    • dicOutput: ((x: R) => R)
        • (x): R
        • Parameters

          Returns R

    • dicInput1: (() => T1)
    • dicInput2: (() => T2)

    Returns (() => Promise<R>) & {
        raw: ((x1: T1, x2: T2) => Promise<R>);
    }

  • Type Parameters

    • R
    • T1
    • T2
    • T3

    Parameters

    • effect: ((x1: T1, x2: T2, x3: T3) => Promise<R>)
        • (x1, x2, x3): Promise<R>
        • Parameters

          Returns Promise<R>

    • dicOutput: ((x: R) => R)
        • (x): R
        • Parameters

          Returns R

    • dicInput1: (() => T1)
    • dicInput2: (() => T2)
    • dicInput3: (() => T3)

    Returns (() => Promise<R>) & {
        raw: ((x1: T1, x2: T2, x3: T3) => Promise<R>);
    }

  • Type Parameters

    • R
    • T1
    • T2
    • T3
    • T4

    Parameters

    • effect: ((x1: T1, x2: T2, x3: T3, x4: T4) => Promise<R>)
        • (x1, x2, x3, x4): Promise<R>
        • Parameters

          Returns Promise<R>

    • dicOutput: ((x: R) => R)
        • (x): R
        • Parameters

          Returns R

    • dicInput1: (() => T1)
    • dicInput2: (() => T2)
    • dicInput3: (() => T3)
    • dicInput4: (() => T4)

    Returns (() => Promise<R>) & {
        raw: ((x1: T1, x2: T2, x3: T3, x4: T4) => Promise<R>);
    }

  • Type Parameters

    • R
    • T1
    • T2
    • T3
    • T4
    • T5

    Parameters

    • effect: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5) => Promise<R>)
        • (x1, x2, x3, x4, x5): Promise<R>
        • Parameters

          Returns Promise<R>

    • dicOutput: ((x: R) => R)
        • (x): R
        • Parameters

          Returns R

    • dicInput1: (() => T1)
    • dicInput2: (() => T2)
    • dicInput3: (() => T3)
    • dicInput4: (() => T4)
    • dicInput5: (() => T5)

    Returns (() => Promise<R>) & {
        raw: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5) => Promise<R>);
    }

  • Type Parameters

    • R
    • T1
    • T2
    • T3
    • T4
    • T5
    • T6

    Parameters

    • effect: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6) => Promise<R>)
        • (x1, x2, x3, x4, x5, x6): Promise<R>
        • Parameters

          Returns Promise<R>

    • dicOutput: ((x: R) => R)
        • (x): R
        • Parameters

          Returns R

    • dicInput1: (() => T1)
    • dicInput2: (() => T2)
    • dicInput3: (() => T3)
    • dicInput4: (() => T4)
    • dicInput5: (() => T5)
    • dicInput6: (() => T6)

    Returns (() => Promise<R>) & {
        raw: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6) => Promise<R>);
    }

  • Type Parameters

    • R
    • T1
    • T2
    • T3
    • T4
    • T5
    • T6
    • T7

    Parameters

    • effect: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7) => Promise<R>)
        • (x1, x2, x3, x4, x5, x6, x7): Promise<R>
        • Parameters

          Returns Promise<R>

    • dicOutput: ((x: R) => R)
        • (x): R
        • Parameters

          Returns R

    • dicInput1: (() => T1)
    • dicInput2: (() => T2)
    • dicInput3: (() => T3)
    • dicInput4: (() => T4)
    • dicInput5: (() => T5)
    • dicInput6: (() => T6)
    • dicInput7: (() => T7)

    Returns (() => Promise<R>) & {
        raw: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7) => Promise<R>);
    }

  • Type Parameters

    • R
    • T1
    • T2
    • T3
    • T4
    • T5
    • T6
    • T7
    • T8

    Parameters

    • effect: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8) => Promise<R>)
        • (x1, x2, x3, x4, x5, x6, x7, x8): Promise<R>
        • Parameters

          Returns Promise<R>

    • dicOutput: ((x: R) => R)
        • (x): R
        • Parameters

          Returns R

    • dicInput1: (() => T1)
    • dicInput2: (() => T2)
    • dicInput3: (() => T3)
    • dicInput4: (() => T4)
    • dicInput5: (() => T5)
    • dicInput6: (() => T6)
    • dicInput7: (() => T7)
    • dicInput8: (() => T8)

    Returns (() => Promise<R>) & {
        raw: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8) => Promise<R>);
    }

  • Type Parameters

    • R
    • T1
    • T2
    • T3
    • T4
    • T5
    • T6
    • T7
    • T8
    • T9

    Parameters

    • effect: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9) => Promise<R>)
        • (x1, x2, x3, x4, x5, x6, x7, x8, x9): Promise<R>
        • Parameters

          Returns Promise<R>

    • dicOutput: ((x: R) => R)
        • (x): R
        • Parameters

          Returns R

    • dicInput1: (() => T1)
    • dicInput2: (() => T2)
    • dicInput3: (() => T3)
    • dicInput4: (() => T4)
    • dicInput5: (() => T5)
    • dicInput6: (() => T6)
    • dicInput7: (() => T7)
    • dicInput8: (() => T8)
    • dicInput9: (() => T9)

    Returns (() => Promise<R>) & {
        raw: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9) => Promise<R>);
    }

  • Type Parameters

    • R
    • T1
    • T2
    • T3
    • T4
    • T5
    • T6
    • T7
    • T8
    • T9
    • T10

    Parameters

    • effect: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9, x10: T10) => Promise<R>)
        • (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10): Promise<R>
        • Parameters

          Returns Promise<R>

    • dicOutput: ((x: R) => R)
        • (x): R
        • Parameters

          Returns R

    • dicInput1: (() => T1)
    • dicInput2: (() => T2)
    • dicInput3: (() => T3)
    • dicInput4: (() => T4)
    • dicInput5: (() => T5)
    • dicInput6: (() => T6)
    • dicInput7: (() => T7)
    • dicInput8: (() => T8)
    • dicInput9: (() => T9)
    • dicInput10: (() => T10)

    Returns (() => Promise<R>) & {
        raw: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9, x10: T10) => Promise<R>);
    }