How to use the @effectful/es-persist-serialization.regConstructor 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-boxes / kit.js View on Github external
class Share {
  constructor(iterable) {
    this.iterator = iterable[Symbol.asyncIterator]
      ? iterable[Symbol.asyncIterator]()
      : iterable[Symbol.iterator]();
  }
  next() {
    return this.iterator.next();
  }
  [Symbol.asyncIterator]() {
    return this;
  }
}

R.regConstructor(Share);
if (typeof DOMRect !== "undefined") R.regConstructor(DOMRect);

export function share(iterable) {
  return new Share(iterable);
}

export const pipe = (...args) => (input, dispatch) =>
  args.reduce((interm, step) => step(share(interm), dispatch), input);

export function run(...args) {
  const { producer, event } = createProducer();
  const main = pipe(...args);
  R.regOpaqueObject(main);
  return main(producer, event);
}

function id(v) {
github awto / effectfuljs / samples / persist-counters / fork.js View on Github external
thread.value = value;
    thread.done = done;
    this.cont.resume(thread);
  }
  reject(e) {
    this.cont.reject(e);
  }
}

function forkCont(i) {
  const res = R.lock();
  i.task[R.awaitSymbol](new ForkCont(i, res));
  return res;
}

R.regConstructor(ForkCont);

async function* handleDelete(input) {
  for await (const i of input) {
    yield i;
    if (i.type === "DELETE") {
      for await (const i of input) {
        if (i.type === "FLUSH") {
          yield i;
          return;
        }
      }
    }
  }
}
github awto / effectfuljs / samples / persist-boxes / kit.js View on Github external
class Share {
  constructor(iterable) {
    this.iterator = iterable[Symbol.asyncIterator]
      ? iterable[Symbol.asyncIterator]()
      : iterable[Symbol.iterator]();
  }
  next() {
    return this.iterator.next();
  }
  [Symbol.asyncIterator]() {
    return this;
  }
}

R.regConstructor(Share);
if (typeof DOMRect !== "undefined") R.regConstructor(DOMRect);

export function share(iterable) {
  return new Share(iterable);
}

export const pipe = (...args) => (input, dispatch) =>
  args.reduce((interm, step) => step(share(interm), dispatch), input);

export function run(...args) {
  const { producer, event } = createProducer();
  const main = pipe(...args);
  R.regOpaqueObject(main);
  return main(producer, event);
}