Function diScope

Incapsulate state managment inside particular scope

const sum = dis((sum, n) => sum + n, 0)
const scope1 = diScope({sum})
const scope2 = diScope({sum})

scope1.sum(1)
scope1.sum(4)
scope1.sum() // 5

scope2.sum(3)
scope2.sum(7)
scope2.sum() // 10
  • Type Parameters

    • T extends {
          [key: string]: Function;
      }

    Parameters

    • scope: T
    • Optionalinit: (() => void)
        • (): void
        • Returns void

    Returns T