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

xr-app-loader

v1.0.29

Published

## 特点

Downloads

12

Readme

xr-app-loader

特点

  • 这是一个基于react, redux, immutable的开源项目
  • 简化原生redux实现状态管理的过程
  • 以app的方式隔离状态和代码
  • 单页程序,通过提供不同app path装载不同应用
  • 每个app模式统一,维护性,大规模开发,项目管理更加容易

适用人员

有react, redux经验的人员

运行example

$ cd example
$ npm install
$ npm start
浏览器访问127.0.0.1:8089

从头开始创建app

$ sudo npm i -g xr-tools
$ xr-tools app -i helloWorld
$ cd helloWorld
$ xr-tools app -c -s helloWorld
$ npm install
$ npm start
浏览器访问127.0.0.1:8089

创建有嵌套关系的app(example例子是用这种方式创建的)

$ sudo npm i -g xr-tools
$ xr-tools app -i demo
$ cd demo/src
$ mkdir apps
$ cd apps
$ xr-tools app -i about
$ xr-tools app -i helloWorld
$ cd ../..
$ xr-tools app -c -s demo
$ 修改src目录下的component.js,action.js,reducer.js可以参考example
$ npm install
$ npm start
浏览器访问127.0.0.1:8089

API

npm install xr-app-loader --save

属性 | 说明 | 类型 -----|-----|----- AppLoader | app包路径 | ReactNode config| 配置,主要配置有使用的app | object start| 启动, 入口参数(targetDomId:目标domid, middlewares:redux中间件, startAppName:开始启动的app名)

AppLoader组件属性

属性 | 说明 | 类型 -----|-----|----- name | app名 | string

this.props包含属性介绍

属性 | 说明 | 数据类型 -----|-----|----- action文件中export的所有方法 | component可以通过this.props.action方法名(),调用action文件中export的所有方法 | function payload | 当前应用的状态 | immutable Map appSource | 当前app path,如:apps/helloworld?a=1 | string appPath | 当前app path,不包括'?'后字符串,如:apps/helloworld | string appQuery | 当前app path中'?'后字符串,如:a=1 | string appParams | appQuery转object,如:{a:1} | object

action代码

action纯函数化,定义component事件需要处理的一些行为方法,示例代码如下

export function initView(){
	//injectFuns是appMiddleware注入对象,其中最重要的一个reduce方法可以指定reducer方法名就可以调用
	//避免redux中处理消息的很多代码
	return injectFuns=>{
		injectFuns.reduce('initView')
	}
}
  • injectFuns是appMiddleware注入的,默认包含下面两个方法

属性 | 说明 | 数据类型 -----|-----|----- reduce | reduce方法能调用reducer的方法,格式:reduce(reducer中方法名, 参数1, 参数2...)|function getState | getState方法能取到当前应用的state | function

reducer代码

reducer纯函数化,定义修改状态的方法,由action调用

它里面所有对外的方法第一个参数是state表示旧状态,返回值是新状态

示例代码如下

import {Map} from 'immutable'

export function initView(state=Map() ){
	return state.set('text', '这是hello world app!')
}