Function diseSet

Override side effect dise function within diInit callback

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)
diseSet(fetchUser, id => id === 1 ? {age: 30, id: 1, name: 'Alice'} : null)

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

    • T extends Function

    Parameters

    • fun: {
          raw: T;
      }
      • raw: T
    • replacement: T

    Returns void