@36node/redux-ui 中文文档教程

发布于 4年前 浏览 26 项目主页 更新于 3年前

Redux ui

versiondownloads

Use

Config redux:

import { reduxUiReducers } from "@36node/redux-ui";

combineReducers({
  ...reduxUiReducers,
});

Assign

将任何值保存到 redux。

actions:

import { createAssignActions } from "@36node/redux-ui/assign";

const assignActions = createToggleActions("someKey");

// set action: set value
dispath(assignActions.set(someValue));

selector:

import { createAssignSelector } from "@36node/redux-ui/assign";

// selector maker
const selector = createAssignSelector("someKey");

const assign = selector(state).assign;

Toggle

打开或关闭切换到 redux。

actions:

import { createToggleActions } from "@36node/redux-ui/toggle";

const toggleActions =  createToggleActions("someKey"),

// open toggle action
dispath(toggleActions.open());

// close toggle action
dispath(toggleActions.close());

// set toggle action
dispath(toggleActions.set(true or false));

selector:

import { createToggleSelector } from "@36node/redux-ui/toggle";

// selector maker
const selector = createToggleSelector("someKey");

const toggle = selector(state).toggle;

Progress

在 redux 中表示一个进度逻辑。

actions:

import { createProgressActions } from "@36node/redux-ui/progress";

const progressActions = createProgressActions("someKeys");

// increase action, default step = 1
dispatch(progressActions.increase(5));
// decrease action, default step = 1
dispatch(progressActions.decrease(5));
// init action, default params: step = 1, min = 0, max = 100
dispatch(progressActions.init(1, 0, 100));

selector:

import { createProgressSelector } from "@36node/redux-ui/progress";

const selector = createProgressSelector("someKey");

// progressState: {step, min, max}
const progressState = selector(state);

Redux ui

versiondownloads

Use

Config redux:

import { reduxUiReducers } from "@36node/redux-ui";

combineReducers({
  ...reduxUiReducers,
});

Assign

Save any value to redux.

actions:

import { createAssignActions } from "@36node/redux-ui/assign";

const assignActions = createToggleActions("someKey");

// set action: set value
dispath(assignActions.set(someValue));

selector:

import { createAssignSelector } from "@36node/redux-ui/assign";

// selector maker
const selector = createAssignSelector("someKey");

const assign = selector(state).assign;

Toggle

Open or close a toggle to redux.

actions:

import { createToggleActions } from "@36node/redux-ui/toggle";

const toggleActions =  createToggleActions("someKey"),

// open toggle action
dispath(toggleActions.open());

// close toggle action
dispath(toggleActions.close());

// set toggle action
dispath(toggleActions.set(true or false));

selector:

import { createToggleSelector } from "@36node/redux-ui/toggle";

// selector maker
const selector = createToggleSelector("someKey");

const toggle = selector(state).toggle;

Progress

Represent an progress logic in redux.

actions:

import { createProgressActions } from "@36node/redux-ui/progress";

const progressActions = createProgressActions("someKeys");

// increase action, default step = 1
dispatch(progressActions.increase(5));
// decrease action, default step = 1
dispatch(progressActions.decrease(5));
// init action, default params: step = 1, min = 0, max = 100
dispatch(progressActions.init(1, 0, 100));

selector:

import { createProgressSelector } from "@36node/redux-ui/progress";

const selector = createProgressSelector("someKey");

// progressState: {step, min, max}
const progressState = selector(state);
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文