1.4.1 • Published 3 years ago

@biscuit-store/core v1.4.1

Weekly downloads
301
License
MIT
Repository
github
Last release
3 years ago

biscuit

JavaScript library for application state-management.

Build Status Typescript npm version release Build Status download

Twitter

Official library website

Description

Biscuit is a modular tool for creating and editing configurable containers for managed states. The goal of the Biscuit-store is to simplify the process of working with states as much as possible, while at the same time providing a consistent architectural approach.

Advantages:

  • Flexible architecture
  • immutable
  • Asynchronous out of the box
  • React support
  • Simple extension with middleware
  • Easy debugging

The approach to creating containers in a biscuit is simple and can be described using the example of creating a duck:

  1. Create a duck;
  2. Tell the duck that it is by definition a duck so it must swim, quack and fly;
  3. Teach the duck to swim, fly and quack.

Installation

Installation of core files

npm install @biscuit-store/core

installing the adapter extension

npm install @biscuit-store/adapter 

Installing an extension to share with react

npm install @biscuit-store/react 

Documentation

Help


Basic exemple

This example describes the process of creating a repository using the createStore method.

import { createStore } from "@biscuit-store/core";
import { connect } from "./counterAdapter";

const { store, actions } = createStore({
  name: "counter",
  initial: { value: 0 },
  actions: {
    increment: "increment/action",
    decrement: "decrement/action"
  },
  middleware: [connect]
});

const { increment, decrement } = actions;

increment.subscribe(() => {
  console.log("incremented");
})

decrement.subscribe(() => {
  console.log("decremented");
})

store.subscribe(({ value }) => {
  console.log("count:", value);
})

increment.dispatch({value: 1});

The adapter module is used for encapsulated state management.

import { createAdapter } from "@biscuit-store/adapter";
const { action, connect } = createAdapter();

action("increment/action", ({ payload, state }) => {
  state.value += payload.value;
});

action("decrement/action", ({ payload, state }) => {
  state.value -= payload.value;
});

export { connect };

Edit Biscuit-store/example-javascript

Example with combined actions

Combined actions are a way to create a repository with built-in managed states. This approach is ideal for stores with a small logical load.

import { createStore } from "@biscuit-store/core";

const { actions } = createStore({
  name: "counter",
  initial: { value: 0 },
  combineActions: {
    increment: (state) => {
      state.value += 1;
    },
    decrement: (state) => {
      state.value -= 1;
    },
  }
});

const { increment, decrement } = actions;

increment.dispatch().after(({ value }) => {
   console.log("count:", value);
});

Edit Biscuit-store/example-javascript (forked)

Some more examples

Tested in browsers

Platform
Version48+11+25+40+9+
Checked

Contributing

If you liked the library, you have many ways to help it develop.

  • You can write about the biscuit-store on various forums;
  • Put a star on github;
  • Write about the bugs found and suggest improvements;
  • Participate in the development, offer your pull request;
  • Or you can just help financially;

The rules of assistance can be found here.

Donate

Any financial help will help the biscuit to become better.

Inspiration

The idea of developing this library was inspired by the Redux project. During the introduction to the biscuit-store, you will see several patterns that are similar to the concepts of Redux. Nevertheless, biscuit is a separate library that uses completely different architectural principles.

Feedback

If you have any questions, suggestions, comments, suggestions for cooperation, or if you like the library and want to become a sponsor, please contact the developer by email: biscuitstorejs@gmail.com.

Changelog

You can see the list of changes here

Adolescence

  • The library is still young and is in beta testing, for this reason, you may stumble upon bugs and flaws. Please be constructive and help us make this tool better.
  • The developer is not a full-fledged native speaker of English, for this reason, there may be errors and tautologies in the documentation, if you have the opportunity to make the documentation better, then I will be glad of any help.

License

Copyright (c) 2021 Philipp Zhulev

MIT License (MIT).

1.4.1

3 years ago

1.4.0

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.3.0

3 years ago

1.2.9

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

2.0.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

0.9.96

3 years ago

0.9.97

3 years ago

0.9.98

3 years ago

0.9.99

3 years ago

0.9.95

3 years ago

0.9.92

3 years ago

0.9.93

3 years ago

0.9.94

3 years ago

0.9.91

3 years ago

0.9.90

3 years ago

0.9.89

3 years ago

0.9.88

3 years ago

0.9.85

3 years ago

0.9.86

3 years ago

0.9.87

3 years ago

0.9.83

3 years ago

0.9.84

3 years ago

0.9.82

3 years ago

0.9.78

3 years ago

0.9.79

3 years ago

0.9.74

3 years ago

0.9.75

3 years ago

0.9.76

3 years ago

0.9.77

3 years ago

1.1.6

3 years ago

0.9.71

3 years ago

0.9.72

3 years ago

0.9.73

3 years ago

0.9.81

3 years ago

0.9.80

3 years ago

0.9.66

3 years ago

0.9.63

3 years ago

0.9.64

3 years ago

0.9.65

3 years ago

0.9.60-beta

3 years ago

0.9.61

3 years ago

0.8.54-beta

3 years ago

0.8.53-beta

3 years ago

0.8.52-beta

3 years ago

0.8.51-beta

3 years ago

0.8.48-beta

3 years ago

0.8.49-beta

3 years ago

0.8.47-beta

3 years ago

0.8.46-beta

3 years ago

0.8.45-beta

3 years ago

0.8.43-beta

3 years ago

0.8.44-beta

3 years ago

0.8.42-beta

3 years ago

0.8.41-beta

3 years ago

0.8.4-beta

3 years ago

0.8.3-beta

3 years ago

0.8.2-beta

3 years ago

0.8.1-beta

3 years ago

0.8.7

3 years ago

0.8.6

3 years ago

0.8.5

3 years ago

0.8.4

3 years ago

0.8.1

3 years ago