lxsmnsyc / riptide

An experimental state management library. Write Observables like you write React Hooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

riptide

An experimental state management library. Write Observables like you write React hooks.

Install

yarn

yarn add @lxsmnsyc/riptide

npm

npm install @lxsmnsyc/riptide

Example

import riptide from '@lxsmnsyc/riptide';

const counter = riptide.createColdRiptide(() => {
  const [state, setState] = riptide.useState(0);

  if (state > 10) {
    return riptide.complete();
  }

  setState(state + 1);

  return riptide.next(state);
});

counter.subscribe({
  next(value) {
    console.log(`Received: ${value}`);
  },
  error(value) {
    console.log(value);
  },
  complete() {
    console.log(`Counter completed!`);
  },
});

License

MIT © lxsmnsyc

About

An experimental state management library. Write Observables like you write React Hooks

License:MIT License


Languages

Language:TypeScript 96.4%Language:JavaScript 3.6%