A library for updating your immutable state in JavaScript applications.

Overview

ionic-bond


Auto Test CI Publish CI npm version

A library for updating immutable states in JavaScript applications.

Introduction

This library is a very lightweight replacement for immer, the core implementation also uses the magic of Proxy, but the exported API only has a solvent function.

In other words, if you are worried about cumbersome code like below, you can try ionic-bond without having to include a huge immer.

setState((prev) => ({
  ...prev,
  userStore: {
    ...prev.userStore,
    currentUser: {
      ...prev.userStore.currentUser,
      userName: "some updated user name",
    },
  },
}));

With ionic-bond, your code will look like this:

import { solvent } from "ionic-bond";

setState(
  (prev) =>
    solvent() // If you are using `TypeScript`, you can use `solvent<YourType>()` to get type inference for the `obj` parameter.
      .ionize((obj) => obj.userStore.currentUser.userName)
      .dissolve(prev)
      .crystallize("some updated user name") // will return a new object with replaced `userName`
);

The reason for these API names is updating object in this form is much like dissolving some crystals in a solvent, then replacing some of the ions in the solution and recrystallizing.

Although these APIs can be designed as a function that accepts three parameters, in order to facilitate the reuse of property selectors and objects before updating, they are hierarchical, that is, curried at the API level.

License

 __________________
< The MIT license! >
 ------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
You might also like...

Proof of concept: support immutable trpc servers using lambdas to ensure client/server compatibility

auto-versioned-trpc-aws-lambda Proof of concept to support an automatically versioned AWS Lambda running tRPC to ensure a somewhat graceful and automa

Aug 30, 2022

Interplanetary Database: A Database built on top of IPFS and made immutable using Ethereum blockchain.

IPDB IPDB (Interplanetary Database) is a key/value store database built on top of IPFS (Interplanetary File System). Project is intended to be an MVP

Oct 6, 2022

A prototype on how web3 technology can enable us to build an open, immutable, reproducible, and permanently accessible scientific record.

A prototype on how web3 technology can enable us to build an open, immutable, reproducible, and permanently accessible scientific record.

Web3 Research A prototype on how web3 technology can enable us to build an open, immutable, reproducible, and permanently accessible scientific record

Nov 27, 2022

📦 Fully typed and immutable store made on top of Immer with mutation, action, subscription and validation!

Riux is a fully typed and immutable store made on top of Immer with mutation, action, subscription and validation! Table of contents 👀 Installation U

Aug 27, 2022

A tiny, reactive JavaScript library for structured state and tabular data.

A JavaScript library for structured state. Using plain old JavaScript objects to manage data gets old very quickly. It's error-prone, tricky to track

Jan 1, 2023

A tiny JavaScript library to easily toggle the state of any HTML element in any contexts, and create UI components in no time.

A tiny JavaScript library to easily toggle the state of any HTML element in any contexts, and create UI components in no time.

A tiny JavaScript library to easily toggle the state of any HTML element in any contexts, and create UI components in no time. Dropdown, navigation bu

Nov 25, 2022

A collection of Aurelia 2 example applications showcasing how to build Aurelia 2 applications and other tasks.

Aurelia 2 Examples A monorepository of a treasure trove of Aurelia 2 example applications you can use as a guide to help you build your own applicatio

Dec 29, 2022

Solid.js library adding a services layer for global shared state.

Solid.js library adding a services layer for global shared state.

Solid Services Services are "global" objects useful for features that require shared state or persistent connections. Example uses of services might i

Dec 30, 2022

State based input library for the browser

Inp State based input library for the browser

Mar 23, 2022
Owner
俺だって、本物が欲しい。
null
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Google Chrome release and version info as JSON (self updating)

chrome-versions Self updating repository to store Google Chrome release and version info as JSON. Windows macOS Linux Android TL;DR Use a CDN to fetch

berstend̡̲̫̹̠̖͚͓̔̄̓̐̄͛̀͘ 9 Dec 15, 2022
LiveJSON provides LiveView-like updating for JSON objects rather than DOM elements.

live_json LiveJSON provides LiveView-like updating for JSON objects rather than DOM elements. It works within your existing LiveViews - just use push_

Rich Jones 57 Dec 29, 2022
This is a demo of updating a map to show air quality data for the user’s current location using Next.js Advanced Middleware, powered by Netlify Edge Functions.

Show Local Air Quality Based on the User's Location Use AQI data to show the air quality near the current user. This is built using Next.js Advanced M

Jason Lengstorf 8 Nov 4, 2022
A simple App for creating, deleting and Updating To Do lists.

To-do-list-demo: Add & Remove Learning objectives Use webpack to bundle JavaScript. Learn how to use proper ES6 syntax. Use ES6 modules to write modul

Kasaija Kenneth 7 Oct 18, 2022
A functional, immutable, type safe and simple dependency injection library inspired by angular.

func-di English | 简体中文 A functional, immutable, type safe and simple dependency injection library inspired by Angular. Why func-di Installation Usage

null 24 Dec 11, 2022
Uncensorable, immutable microblogging platform that is completely decentralized and does not rely on any centralized systems.

Zooko Truly decentralized, immutable and uncensorable microblogging Zooko is a working-example, proof-of-concept proving that you can have a decentral

Publius Federalist 152 Apr 20, 2022
Serverless for Web3, which is Immutable and Verifiable✅

Tender Layer 2 for IPFS / API Renderer for Web3 / Serverless for Ethereum Tender is dynamic content serving P2P Protocol for Ethereum. V1 Design A Cod

Hyojun Kim 23 Nov 18, 2022
Functional Programming with NestJS, Prisma. immutable, pure, stateless

Functional-NestJS Functional Programming with NestJS, Prisma. immutable, pure, stateless. 1. Introduction A production ready typescript backend reposi

y0on2q 40 Dec 6, 2022