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

@kun.s/munity

v0.0.4

Published

An opinionated state management library for Angular work with immer.js

Downloads

8

Readme

Coverage Status Build Status

Munity

Munity is an opinionated Angular state management library based on Immer.js. This library is heavily inspired by ngrx, redux-observable.
It is currently WORK IN PROGRESS, but It is fully functional.

To run the sample application npm install , then ng serve

Concepts

  • Effect is an asynchronous operation with state mutation.
  • Mutation is a function takes the current state, payload as input and mutate the state in its body.

Select

To read the content of the store as Rx.js observable

interface StateModel {
    posts:IPost[];
    loading: false
}
// select substate
stateChange = this.store.select((current)=>current.posts);
// select entire store
stateChange = this.store.select();

To just read the current value

interface StateModel {
    posts:IPost[];
    loading: false
}
// select substate
current = this.store.snapshot((current)=>current.posts);
// select entire store
current = this.store.snapshot();

Effect

To make an effect just implement the Effect interface, and provide async operation in task function. Implement IResultOfEffect to provide a selector function to retrieve the result of state mutation

@Injectable({providedIn: 'root'})
export class SideEffectOfLoadPost implements IResultOfEffect<IPost[], State, IPost[]> {
    readonly action: ActionID = 'SET_POSTS';

    constructor(private readonly api: BackendService) {

    }

    selector(state: State) {
        return state.posts;
    }

    task(): Observable<IPost[]> {
        return this.api.getPostList();
    }

}

Mutation

Mutation is just a function placed in store config object, perform state directly on current state.

const postStoreConfig: IStoreConfig<State> = {
    init: {posts: [], name: '', selected: null},
    mutations: {
        SET_POSTS: (current: State, payload: IPost[]) => {
            current.posts = payload;
        },
        SET_SELECTED: (current: State, payload: IPost) => {
            current.selected = payload;
        }
    }
};