UNPKG

@microstates/ember

Version:

Data Down, Actions Up: at the molecular level.

17 lines (14 loc) 384 B
import { set, computed } from "@ember/object"; import { Store } from "../index"; import { stateFrom } from "../-private"; export default function use(typeOrValue, value) { return computed({ get(key) { let initial = stateFrom(typeOrValue, value); return Store(initial, state => set(this, key, state)); }, set(key, state) { return state; } }); }