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

mobx-app-model

v0.2.13

Published

Model structure for application based on mobx

Downloads

14

Readme

mobx-model (experiment)

A simple wrapper around mobx.

Status

It's an experiment. We are going to use it in our project and we are prepared to tweak it until it fits to our use cases.

I cannot recommend anyone to use it in real project because it is in an early stage.

If you like it or have ideas how to improve it I will be happy to hear them.

Instalation

npm install --save mobx-app-model

to use typescript you need also install following typings:

typings install --save --ambient es6-shim
typings install --save --ambient whatwg-fetch

Goals

  • actions which are simple to test
  • targets which are created from these action and can be used directly in react components without binding
  • have composable models
  • posible side effects (this needs to be improved)

Description

  • state - initial state of your model, this creates the state property on the model (mobx observable)
  • actions - methods where model and arguments are passed, they run in mobx transaction
  • inputs - method that enables to create additional inputs that can be connected throug drivers rx subject, ... (see examples - gif-fetcher)
  • init - enables to init model during creation, good for composing other models

Example

    import { modelFactory } from 'mobx-factory';
    import { autorun } from 'mobx';

    export const createModel = modelFactory({ 
        
        state: {
            value: 0
        },
        
        actions: {
            
            reset({state}) {            
                state.value = 0;
            },
            
            increment({state}) {
                state.value += 1;
            },
            
            decrement({state}) {
                state.value -= 1;
            },
            
            set({state}, value) {
                value = parseInt(value, 10);
                state.value = isNaN(value) ? null : value;
            }        
        }
    });

    const model = createModel();

    autorun(() => {
        console.log(model.state.value);
    });
    
    model.targets.increment(); // 1
    model.targets.increment(); // 2    

Comments

Some of the ideas cames from the previous experiment