import { Stream } from 'effection'; /** * A slice represents a piece of the atom. Each part of the state can be * updated and retrieved. Any update will cause the entire state of the atom to * be updated. */ export interface Slice extends Stream { /** * Retrieve the current value of the slice */ get(): S; /** * Set the value of the slice to the given value */ set(value: S): void; /** * Update the value of the slice with the given function. The function takes * the current value as an argument and should return the new value. * * @param fn a function which updates the state */ update(fn: (state: S) => S): void; /** * Return a new {@link Slice} for the given path. */ slice: MakeSlice; /** * Remove this slice from its parent */ remove(): void; /** * Return a stream for this slice. Convenient for destructuring assignment. * * ### Example * * ```typescript * import { main } from 'effection'; * import { createAtom } from '@effection/atom'; * * main(function*() { * let { stream, set } = createAtom(0); * * yield spawn(stream.forEach((number) => console.log(number))); * set(1); * }); * ``` */ stream: Stream; } export interface MakeSlice { (): S; (key: Key): Slice; (key1: Key1, key2: Key2): Slice; (key1: Key1, key2: Key2, key3: Key3): Slice; (key1: Key1, key2: Key2, key3: Key3, key4: Key4): Slice; (key1: Key1, key2: Key2, key3: Key3, key4: Key4, key5: Key5): Slice; (key1: Key1, key2: Key2, key3: Key3, key4: Key4, key5: Key5, key: Key6): Slice; (key1: Key1, key2: Key2, key3: Key3, key4: Key4, key5: Key5, key: Key6, key7: Key7): Slice; (key1: Key1, key2: Key2, key3: Key3, key4: Key4, key5: Key5, key: Key6, key7: Key7, key8: Key8): Slice; } //# sourceMappingURL=types.d.ts.map