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

@misk/simpleredux

v0.6.3

Published

Misk-Web SimpleRedux

Downloads

15,761

Readme

Misk Simple Redux

Using Redux can be simple.

@misk/SimpleRedux includes all the Redux parts necessary for forms, network requests, and other interactive components. Don't write Redux boilerplate for basic interactivity again.

Getting Started

$ npm install @misk/simpleredux

SimpleSelector

simpleSelectorGet

  • Allows for single-key cached selection from Redux state

  • Most directly equivalent to deprecated simpleSelect

    // OLD
    const field1 = simpleSelect(props.simpleForm, "Dino::Field1", "data")
    const tagsField = simpleSelect(props.simpleForm, "Dino::Tags", "data", simpleType.array)
    
    // NEW
    const field1 = simpleSelectorGet(props.simpleForm, ["Dino::Field1", "data"])
    const tagsField = simpleSelectorGet(props.simpleForm, ["Dino::Tags", "data"], [])
  • simpleSelectorGet

    • subState: same as parameter 1 for simpleSelect. Example: props.simpleForm, props.simpleNetwork
    • path: allows any length path to an object key you'd like to access. This combines parameter 2 and 3 of simpleSelect.
      • Examples: "Dino::Name.data", ["Dino::Price", "data"]
      • Same as parameter in Lodash/Get
    • defaultValue? is optional and allows setting of a default value if the requested path is not found.
      • Examples: false, [], {}
      • This is useful for cases like storing a list of tags where the UI expects an empty array [] in the case of no elements, not undefined.
      • Same as parameter in Lodash/Get

simpleSelectorPick

  • Allows for multi-key cached selection from Redux state

    // OLD
    const fields = [
      "Name",
      "Price",
      "Itemized Receipt",
      "CheckAlice",
      "CheckBob",
      "CheckEve",
      "CheckMallory",
      "CheckTrent",
      "Meal",
      "Tags"
    ].map((f: string) => `Dino::${f}`)
    const fieldsData = fields
      .map((key: string) => {
        const value = simpleSelect(props.simpleForm, key, "data")
        return { [key]: value }
      })
      .reduce((prev, current) => ({...prev, ...current}), {})
    
    // New
    const fields = [
      "Name",
      "Price",
      "Itemized Receipt",
      "CheckAlice",
      "CheckBob",
      "CheckEve",
      "CheckMallory",
      "CheckTrent",
      "Meal",
      "Tags"
    ].map((f: string) => `Dino::${f}.data`)
    const fieldsData = simpleSelectorPick(props.simpleForm, fields)
  • simpleSelectorPick

    • subState: same as parameter 1 for simpleSelect.
      • Example: props.simpleForm, props.simpleNetwork
    • paths: array of paths of keys to return from object.
      • Example: ["Dino::Name.data", "Dino::Price.data"]
      • Same as parameter in Lodash/Pick

Merge and Failure Sagas

Dispatched actions can include an options object that has two very powerful keys:

  • mergeSaga
  • failureSaga

These are Redux sagas that are run on merge (success) or failure and allow for an additional async block of computation that include other network calls, seeding to many fields parts of the network response data, and anything else.

Both mergeSaga and failureSaga follow the same generic Redux Saga API. Consider looking at the src/saga.ts or src/utilities/mergeSaga.ts code to find examples of sagas already part of @misk/simpleredux.

Resources

DEPRECATED: SimpleForm

A standardized set of form and input handler Redux-Sagas parts (actions, dispatcher, handlers, sagas, reducers, state interface)

DEPRECATED: SimpleNetwork

A standardized set of Axios based request Redux-Sagas parts (actions, dispatcher, handlers, sagas, reducers, state interface)

Releasing

Changelog (and Breaking Changes)