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

redux_live

v1.0.0

Published

```bash npm install --save https://github.com/mystand/redux-live.git ```

Downloads

3

Readme

Installation

npm install --save https://github.com/mystand/redux-live.git

Install saga

// After store initialization
sagaMiddleware.run(rootSaga, store.dispatch)


// In root saga creation
import { buildRequestsSaga } from 'redux_live'
import Api from 'path/to/api'

export default function *rootSaga(dispatch) {
  const requestsSaga = buildRequestsSaga(Api, dispatch)

  yield [
    // ...
    requestsSaga()
  ]
}

Install reducer

import { combineReducers } from 'redux'
import { requestsReducer } from 'redux_live'

const reducers = {
  // ... your other reducers here ...
  requests: formReducer     // <---- Mounted at 'requests'
}
const reducer = combineReducers(reducers)

Usage

Create actions

// actions/actsActions

import { requestsActionsHelper } from 'redux_live'

const { generateIndex, generateGet, generateCreate } = requestsActionsHelper

export const index = generateIndex('acts') // calls Api.acts.index method(params)
export const get = generateGet('acts') // calls Api.acts.get method(params)
export const create = generateCreate('acts') // calls Api.acts.create method(params)

Connect to component

type RequestResultType<T> = {
  data: T,
  failureError: any,
  dataError: any,
  loading: boolean
}

type ActType = { 
  // ...
} 

type PropsType = {
  actsResult: RequestResultType<Array<ActType>>  
}

const ActsPage = (props: PropsType) => {
  const { actsResult } = props
  if (actsResult == null || actsResult.loading) return <div>Loading</div>
  if (actsResult.failureError || actsResult.dataError) return <div>Error</div>

  const acts = actsResult.data
  // ...  
}

export default connectWithRequests([
  {
    key: 'acts',
    action: () => actsActions.index()
  }
])(ActsPage)

Dispatch one action

// actions/issuesActions

import { requestsActionsHelper } from 'redux_live'
const { generateCreate } = requestsActionsHelper

export const create = generateCreate('acts') // calls Api.acts.create method
import * as issuesActions from 'actions/issuesActions'

const CreateIssueModal = (props: PropsType) => {
  const { handleSubmit, dispatchRequest } = props // <- get dispatchRequest from props 

  const onSubmit = handleSubmit((values: HashType) => {
    const params = { record: values }
    const requestKey = 'createIssue'
    dispatchRequest(issuesActions.create(requestKey, params)) // <- use dispatchRequest with any requestKey
  })

  return (
    // ...
  )
}

export default R.compose(
  reduxForm({ form: 'createIssue' }),
  connectWithRequests([])
)(CreateIssueModal)

Customize api method name in action creator


 import { requestsActions } from 'redux_live'
 
 // this methos calls Api.project.dashboard(params)
 // params will be same as params from action
 export const dashboard = (requestKey: string, params?: HashType, options?: OptionsType) => ({
   type: requestsActions.REQUEST_START,
   method: 'dashboard',
   dataType: 'project',
   requestKey, params, options
})

Infinity scroll

There are two merge option values. replace (by default) and append (append for arrays only)

export default connectWithRequests([
  {
    key: 'messages',
    cacheKey: (props: PropsType, state: StateType) => state.offset.toString(),
    action: (props: PropsType, state: StateType) => {
      const { offset } = state
      return messagesActions.index(null, { offset, limit: LIMIT }, { merge: 'append' }) // <- use merge: append
    }
  }
])(ProjectIssuePage)

Subscriptions

You can white condition using syntax provided by JEXT

export default connectWithRequests([
  {
    key: 'issues',
    cacheKey: (props: PropsType) => props.params.projectId,
    action: (props: PropsType) => issuesActions.index(null, { projectId: props.params.projectId }, {
      subscribe: {
        model: 'Issue',
        condition: `o.project_id == ${props.params.projectId}` // see https://www.npmjs.com/package/jexl
      }
    })
  }
])(ProjectSupportPage)

Ordering

It correctly works with subscriptions

export default connectWithRequests([
  {
    key: 'issues',
    cacheKey: (props: PropsType) => props.orderField,
    action: (props: PropsType) => issuesActions.index(null, {}, {
      comparator: (a, b) => a[props.orderField] - b[props.orderField],
      subscribe: { model: 'Issue' }
    })
  }
])(IssuesPage)

Subscription query scoping

If it needs you can use getUrlOptions parameter to custom your get/index subscription requests, this option fully supported by changes-notifier server.

export default connectWithRequests([
  {
    key: 'issues',
    cacheKey: (props: PropsType) => props.orderField,
    action: (props: PropsType) => issuesActions.index(null, {}, {
      comparator: (a, b) => a[props.orderField] - b[props.orderField],
      subscribe: { 
        model: 'Issue', 
        getUrlOptions: {
          showHidden: true
        }
      }
    })
  }
])(IssuesPage)