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

fun-model

v7.0.1

Published

fun-model is pure functional implementation of FLUX architecture.

Downloads

73

Readme

FUN-Model

  • is pure functional implementation of FLUX architecture
  • Why FUN?
  • f - functional
  • u - unidirectional
  • n - whatever
  • model - just Model or ViewModel

Resources

  • Bobril,
  • Flux,
  • Reflux,
  • Redux
  • reducers + flux
  • immutability
  • pure functionality
  • https://www.youtube.com/watch?v=xsSnOQynTHs

Wiki

Notes

Common keywords

  • 1 store with 1 global application state
  • application state is composition of sub states
  • cursors are pointers to sub states
  • action calls handler function with specific cursor
  • immutability
  • replaces part of global state
  • creates new instance of state
  • Bobril and React are only rendering tools
  • "components are stateless"
  • support for unit testing
  • we need rendering (frame) for each visible modification

Lifecycle

  • Store - persists global application state
  • Views/Pages - GUI stateless components
  • Actions - creates new state or sub states for global application state
    • Cursors - pointers to sub states
    • Handlers - new state creators which get current state for specific cursor and give new instance of the same state type
  • Action creator
    • gets state for handlers by cursor from global state
    • sets new state from handlers
    • if new state isn't same as previous frame then calls render for new frame

Immutable or Mutable?

  • immutable object is an object that has sub objects which can't be never mutated
  • otherwise if you have mutable object you can do everything with its sub objects
  • e.g. push new item into array:
  • mutable:
let newLength = array.push(newItem)
  • immutable:
    • just create new array
let newInstanceOfArrayState = [...oldArrayState, newItem]; // it's pretty easy  
let oldStateAsSameInstance = [...oldArrayState]; // beware doesn't work  

The common mutability

  • let's call action which changes name of third group in graph component
  • green balls marks which instances are created again

  • next frame renders all components of application (we haven't got router for page 1 to page N)
  • router might be optimization for question. What should be rendered again in next frame?
    • renders only one page which is derived from current URL
  • what we can do with page rendering optimization?
  • immutability and instance comparing might be option???

The immutability with deep copy

  • green balls mark which instances are created again
  • we make decision in next frame what should be rendered again?
  • we create comparing between current state or sub state with previous state or sub state
  • when states are same we don't need rendering
  • when states aren't same we need rendering

  • when we imagine that every green balls is component which consists of complex DOM structure then all will be rendered. But some balls rendering is unnecessary because they haven't changes in their state, correct???
  • shallow copy in action creator might be optimization

The immutability with shallow copy

  • green balls marks which instances are created again

  • we make decision in next frame what should be rendered again?
  • we create comparing between current state or sub state with previous state or sub state
  • when states are same we don't need rendering
  • when states aren't same we need rendering