Coder Social home page Coder Social logo

reactflowstore's Introduction

ReactFlowStore

A lightweight state management library for React applications. Dive into a reactivity-rich environment powered by RxJS and experience a simpler, straightforward state management approach.

Features

  • Minimalist API
  • Reactive updates with RxJS
  • Convenient hooks for easy React integration
  • Middleware and action creator support
  • Memoization and caching for efficient data retrieval

Installation

Install ReactFlowStore via npm:

npm install react-flow-store

Usage

Create a store:

// store.ts
import { createStore } from "react-flow-store";

const store = createStore({
  state: {
    users: [],
  },
  actions: {
    getUsers({ state }) {
      fetch("some-url")
        .then((res) => res.json())
        .then((users) => {
          state.users = users;
        });
    },
  },
  getters: {
    users({ state }) {
      return state.users;
    },
  },
});

export default store;

Use the store in a React component:

// UserComponent.tsx
import React from "react";
import { useStore } from "react-flow-store";
import store from "./store.ts";

const UserComponent: React.FC = () => {
  const users = useStore(store, "users");

  return (
    <div>
      {users.map((user) => (
        <div key={user.id}>{user.name}</div>
      ))}
    </div>
  );
};

Wrap your app with StoreProvider:

import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import store from "./store";
import { ReactFlowStoreProvider } from "react-flow-store";

ReactDOM.render(
  <ReactFlowStoreProvider store={store}>
    <App />
  </ReactFlowStoreProvider>,
  document.getElementById("root")
);

Documentation

For more detailed documentation and additional examples, please refer to the official documentation (Link when available).

Contributing

Pull requests are welcome. For significant changes, please open an issue first to discuss your proposals. Remember to run tests before submitting your PR!

License

MIT

reactflowstore's People

Contributors

bogdanmartinescu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.