How to use the @effectful/es-persist-serialization.bind function in @effectful/es-persist-serialization

To help you get started, we’ve selected a few @effectful/es-persist-serialization examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github awto / effectfuljs / samples / persist-counters / kit.js View on Github external
export function signal(dispatch, type, value) {
  return R.bind(_signal, null, dispatch, type, value);
}
github awto / effectfuljs / samples / persist-counters / fork.js View on Github external
async function* forkMain(input, dispatch, threads, transducer) {
  let cur = 0;
  for await (const i of input) {
    if (i.type === "ITEM") {
      const thread = threads.get(i.key);
      thread.source.dispatch(i.value);
    } else if (i.type === "NEW") {
      const source = createProducer();
      const key = i.key || ++cur;
      const iter = transducer(
        source,
        R.bind(forkDispatch, null, dispatch, key)
      )[Symbol.asyncIterator]();
      const thread = { iter, key, task: iter.next(), source };
      threads.set(key, thread);
      yield false;
    } else if (i.type === "FLUSH" && threads.size) {
      const awaiting = new Set();
      for (const { source, key } of threads.values()) {
        awaiting.add(key);
        source.dispatch({ ...i, awaiting });
      }
    } else {
      yield i;
    }
  }
}
github awto / effectfuljs / samples / persist-counters / extras.js View on Github external
export async function* incrementAsync(input, dispatch) {
  yield {
    type: "MENU_ITEM",
    index: 300,
    value: (
      <button>
        Increment Async
      </button>
    )
  };
  yield* input;
}
github awto / effectfuljs / samples / persist-boxes / kit.js View on Github external
export function createProducer() {
  const producer = R.producer();
  return { producer, event: R.bind(event, producer) };
}
github awto / effectfuljs / samples / persist-counters / kit.js View on Github external
export function createProducer() {
  const producer = R.producer();
  producer.dispatch = R.bind(resend, producer);
  return producer;
}
github awto / effectfuljs / samples / persist-boxes / kit.js View on Github external
function event(props, propagate) {
  return R.bind(eventHandler, this, props, propagate);
}