Skip to content
/ sn-redux Public
forked from SenseNet/sn-redux

A set of redux actions, reducers and redux-ovbservable epics for Sense/Net ECM

License

Notifications You must be signed in to change notification settings

borsi/sn-redux

 
 

Repository files navigation

sn-redux

Gitter chat Build status Coverage Codacy Badge NPM version NPM downloads License semantic-release Commitizen friendly

sn-redux is a convention driven way of building Sense/Net applications using Redux. It contains all the action types, actions and reducers for built-in Sense/Net Actions and Functions.

sn-redux gives you a standard set of:

  • action types: e.g. ADD_CONTENT_SUCCESS
  • actions: e.g. updateContentSuccess, updateContentFailure
  • reducers: for the action types above e.g. updateContentSuccess
  • epics: for streams of actions that are related to the same process e.g. createContentEpic

Installation on an existing Sense/Net portal

Get the latest stable version with npm

npm install --save sn-redux

or from the GitHub repository and place the downloaded source into your project. If you want to use only the transpiled JavaScript modules, you can find them in the dist/src folder and import them like

var SN = require('/pathtomodule/sn-redux');

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

import { Actions } from 'sn-redux';

store.dispatch(Actions.Delete(123, false));

Installation into an external app with node and npm

To install the latest stable version

npm install --save sn-redux

Set your Sense/Net portal's url with SetSiteUrl method

import { SetSiteUrl } from 'sn-client-js';

SetSiteUrl('https://daily.demo.sensenet.com');

So that you can set the url of your Sense/Net portal that you want to communicate with. To enable your external app to send request against your Sense/Net portal change your Portal.settings. For further information about cross-origin resource sharing in Sense/Net check this article.

Import

CommonJS

var Actions = require('sn-redux').Actions;

store.dispatch(Actions.Delete(123, false));

Typescript

import { Actions } 'sn-redux';

store.dispatch(Actions.Delete(123, false));

Building sn-redux

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

gulp

Running tests

To execute all unit tests, use:

gulp test

Generatings code coverage report

gulp test:coverage

Examples

Combine custom reducer with the built-in ones

import { combineReducers } from 'redux';
import { Reducers } from  'sn-redux';

const collection = Reducers.collection;
const myReducer = combineReducers({
  collection,
  listByFilter
});

Creating a store

import { Store } from  'sn-redux';

const store = Store.configureStore(myReducer);

Using built-in actions

import { Content } from 'sn-client-js';
import { Actions } from 'sn-redux';

const parentPath = '/workspaces/Project/budapestprojectworkspace/tasks';
const content = new Content({
          Type: 'Task',
          DisplayName: 'My first task'
      });

dispatch(Actions.CreateContent(parentPath, content))

Documentation

Influences

Example applications

  • Using Raw Javascript and HTML (TODO)
  • Using React
  • Using Angular (TODO)
  • Using Angular2 (TODO)
  • Using Vue (TODO)
  • Using Aurelia (TODO)
  • Using Ember (TODO)
  • Using Polymer (TODO)
  • Using React Native (TODO)

About

A set of redux actions, reducers and redux-ovbservable epics for Sense/Net ECM

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 97.1%
  • JavaScript 2.9%