npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fp-ts-atom

v3.0.0

Published

State management solution combining fp-ts, RxJS and monocle-ts

Downloads

42

Readme

Test npm version npm downloads


State management solution combining fp-ts, RxJS and monocle-ts

fp-ts-atom aims to befriend RxJS and monocle-ts and provide a convenient way to manage state in a reactive way.

Inspired by @grammarly/focal



Features

  • ♨️ Any Atom is a hot Observable
  • 😪 Lazy initial value evaluation
  • 🏃 Deferred source subscription
  • 🔎 Compatible with Lens from monocle-ts
  • 🌍 Natively extends fp-ts ecosystem
  • 🦺 Type-safe operations
  • 🧪 Covered by tests

Atom

General usage of the Atom is to store an application state. Atom has a get and set methods that allow to read and write the state. Apart from that, Atom is a hot Observable which means that you can listen to changes of the state.

Atom has fp-ts instances: Pointed, FromIO.

import { of } from 'fp-ts-atom/Atom';
const state$ = of(0);
state$.get(); // 0
state$.set(3);
state$.get(); // 3
state$.subscribe(console.log); // "3" in console
state$.set(2); // "2" in console

Atom API Reference

ReadonlyAtom

ReadonlyAtom is useful when you want to protect the state from direct changes. You can derive ReadonlyAtom from Atom using toReadonlyAtom method from Atom module or any other method from ReadonlyAtom module.

ReadonlyAtom has fp-ts instances: Pointed, FromIO, Functor, Apply, Applicative.

import { of } from 'fp-ts-atom/Atom';
import { map } from 'fp-ts-atom/ReadonlyAtom';
const state$ = of({ a: 0 });
const number$ = pipe(state$, map(s => s.a));
number$.get(); // 0
state$.set({ a: 3 });
number$.get(); // 3
number$.subscribe(console.log); // "3" in console
state$.set({ a: 2 }); // "2" in console

ReadonlyAtom API Reference

Install

Uses fp-ts, rxjs and monocle-ts as a peer dependency.

yarn add fp-ts rxjs monocle-ts fp-ts-atom

or

npm install fp-ts rxjs monocle-ts fp-ts-atom