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

usdux

v1.0.2

Published

<img src="./icon.png">

Downloads

1

Readme

usdux

A frontend business framework,build-in common develop feature for fast build application, Build SPA application with MPA store, no redux but compat middlewares, the global store apply with React.createContext

  • ✅ Build-in page and global store
  • ✅ Hocs and hooks to access store
  • ✅ Support redux middlewares
  • ✅ Plugins execute when application start
  • ✅ Integration react-router and allow jsonify router config
  • ✅ Build-in error-boundary and allow customize
  • ✅ Build-in routerError page and allow customize
  • ✅ Build-in auth page logic
  • [todo] Build-in key title description with router
  • [todo] support React suspence and lazy import
  • [todo] support ssr

Install

npm i usdux -S

Usage

quick start

write following code in index.js which starts application

import App from 'usdux'

App({
  routerConfig: {
    staticRouters: [{
      prefix: '/center',
      layout: (props) => props.children,
      title: 'example 1',
      routers: [{
        title: 'home',
        component: () => <div>hello world!</div>,
        path: '/1'
      }]
    }]
  },
})

Class Component

import React from 'react'
import { connect } from 'usdux'

export default @connect class Component extends React.Component {
  handleClick = () => {
    this.props.dispatch({type: 'setGlobal', payload: {a: 1}})
  }

  render() {
    return (<div>
      <div onClick={this.handleClick}>{JSON.stringify(this.props._global_)}</div>
      <div>{JSON.stringify(this.props._page_)}</div>
    </div>)
  }
}

Functional Component


import React from 'react'
import { useStore } from 'usdux'

export default const Component = () => {
  const [store, dispatch] = useStore()
  const handleClick = () => {
    dispatch({type: 'setPage', payload: {a: 1}})
  }

  return (<div>
      <div>{JSON.stringify(store._global_)}</div>
      <div onClick={handleClick}>{JSON.stringify(store._page_)}</div>
    </div>)
}

Store Action

  • setGlobal set global state
dispatch({type: 'setGlobal', payload: 'xxx'})
  • resetGlobal reset global state
dispatch({type: 'resetGlobal'})
  • setPage set page state
dispatch({type: 'setGlobal', payload: 'xxx'})
  • resetPage reset page state
dispatch({type: 'resetPage'})

middlewares

In theory, compat redux-chunk middewares :)

Options

{
  checkLogin: 'function',
  checkAuth: 'function',
  getDynamicRouters: 'function',
  pageError: {
    fallback: 'ReactNode || stirng',
    noMatch: 'ReactNode || string',
    noAuth: 'ReactNode || string',
  },
  staticRouters: [{
    layout: 'ReactNode || string',
    prefix: 'string',
    title: 'string',
    needLogin: 'boolean',
    pageError: {
      fallback: 'ReactNode || stirng',
      noMatch: 'ReactNode || string',
      noAuth: 'ReactNode || string',
    },
    routers: [{
      title: 'string',
      authKey: 'string',
      path: 'string || array',
      needAuth: 'boolean',
      component: 'ReactNode || string',
    }],
  }]
}