Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Jan 4, 2019. It is now read-only.
/sn-reduxPublic archive

A set of redux actions, reducers and redux-ovbservable epics for sensenet

License

NotificationsYou must be signed in to change notification settings

SenseNet/sn-redux

Repository files navigation


This package is not under active development. You can find our latest packages in thesensenset/sn-client monorepo.


Gitter chatBuild statusCoverageCodacy BadgeNPM versionNPM downloadsLicensesemantic-releaseCommitizen friendlyGreenkeeper badge

sn-redux is a convention driven way of building sensenet applications using Redux. It contains all the action types, actions and reducers forbuilt-in sensenet Actionsand Functions.

sn-redux gives you a standard set of:

  • action types: e.g. CREATE_CONTENT_SUCCESS
  • actions: e.g. updateContentSuccess, updateContentFailure
  • reducers: for the action types above e.g. updateContentSuccess

Tested with the following sensenet Services version:

sensenet Services

Installation on an existing sensenet portal

Get the latest stable version with npm

npm install --save @sensenet/redux

or from theGitHub repository and place the downloaded source into your project. If you want to use only the transpiled

If you want to use the module types you can find them in the src folder. Import them the following way:

import { Actions } from '@sensenet/redux';import { Repository } '@sensenet/client-core';import { Task } from '@sensenet/default-content-types';const repository = new Repository({  RepositoryUrl: 'http://path-to-your-portal.com',});const repository = new Repository({  repositoryUrl: 'http://path-to-your-portal.com',})store.dispatch(Actions.deleteContent('/workspaces/MyWorkspace/MyDocs/mydoc.docx', false));

Installation into an external app with node and npm

To install the latest stable version

npm install --save @sensenet/redux

Create your sensenet portal Repository to use. You can configure your Store to use this repository, when calling Store.ConfigureStore

import{Repository}from'@sensenet/client-core';import{Reducers,Store}from'@sensenet/redux';import{combineReducers}from'redux'constsensenet=Reducers.sensenetconstmyReducer=combineReducers({  sensenet})constrepository=newRepository({repositoryUrl:'http://path-to-your-portal.com',})constoptions={  repository,rootReducer:myReducer,}asStore.CreateStoreOptionsconststore=Store.createSensenetStore(options)

To enable your external app to send request against your sensenet portal change yourPortal.settings. For further information about cross-origin resource sharing in sensenet checkthis article.

Check your sensenet portal's web.config and if theODataServiceToken is set, you can pass to your Repository as a config value on client side.

letrepository=newRepository.SnRepository({RepositoryUrl:'http://path-to-your-portal.com',ODataToken:'MyODataServiceToken'});

Import

import { Actions } '@sensenet/redux';import { Task } from '@sensenet/default-content-types'...const content = { Id: 123 } as Task;...store.dispatch(Actions.DeleteContent(content.Id, false));

Building sn-redux

Building the project, running all the unit tests and the ts linter and get the code coverage report, use:

npm run build

Running tests

To execute all unit tests and generate coverage reports, use:

npm t

Examples

Combine custom reducer with the built-in ones

import { combineReducers } from 'redux';import { Reducers } from  '@sensenet/redux';const sensenet = Reducers.sensenet;const myReducer = combineReducers({  sensenet,  listByFilter});

Creating a store

import { Store } from  '@sensenet/redux';import { Repository } from '@sensenet/client-core';const repository = new Repository({  repositoryUrl: 'http://path-to-your-portal.com',})const options = {  repository,  rootReducer: myReducer,} as Store.CreateStoreOptionsconst store = Store.createSensenetStore(options)

Using built-in actions

import { Repository } from '@sensenet/client-core';import { Task } from '@sensenet/default-content-type'import { Actions } from '@sensenet/redux';const repository = new Repository({  repositoryUrl: 'http://path-to-your-portal.com',})const parentPath = '/workspaces/Project/budapestprojectworkspace/tasks';const content = {          Id: 123,          DisplayName: 'My first task'      } as Task);dispatch(Actions.CreateContent(parentPath, content, 'Task'))

Documentation

Influences

Example applications

About

A set of redux actions, reducers and redux-ovbservable epics for sensenet

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp