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

sn-redux

v3.4.3

Published

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

Downloads

59

Readme

sn-redux

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

sn-redux is a convention driven way of building sensenet ECM applications using Redux. It contains all the action types, actions and reducers for built-in sensenet Actions and 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
  • epics: for streams of actions that are related to the same process e.g. createContentEpic

Installation on an existing sensenet ECM 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';
import { Content, ContentTypes, Repository } 'sn-client-js';

let repository = new Repository.SnRepository({
  RepositoryUrl: 'http://path-to-your-portal.com',
});

const content = Content.Create({ Id: 123 }, ContentTypes.Task, repository);
store.dispatch(Actions.Delete(content, false));

Installation into an external app with node and npm

To install the latest stable version

npm install --save sn-redux

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

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

let repository = new Repository.SnRepository({
  RepositoryUrl: 'http://path-to-your-portal.com',
});

const store = Store.configureStore(
    myRootReducer,
    myRootEpic,                   // If not set, the default will be 'Epics.rootEpic'
    [middleware1, middleware2],   // If not set, only the epicMiddleware will be used
    persistedState,               // Optional
    repository                    // Optional. If not provided, a Repository with default values will be used
    );

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

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

let repository = new Repository.SnRepository({
  RepositoryUrl: 'http://path-to-your-portal.com',
  ODataToken: 'MyODataServiceToken'
});

Import

CommonJS

var Content = require('sn-client-js').Content;
var Repository = require('sn-client-js').Repository;
var ContentTypes = require('sn-client-js').ContentTypes;
var Actions = require('sn-redux').Actions;

let repository = new Repository.SnRepository({
  RepositoryUrl: 'http://path-to-your-portal.com',
});

var content = Content.Create({ Id: 123 }, ContentTypes.Task, repository);
store.dispatch(Actions.Delete(123, false));

Typescript

import { Actions } 'sn-redux';
import { Content, ContentTypes, Repository } 'sn-client-js';

let repository = new Repository.SnRepository({
  RepositoryUrl: 'http://path-to-your-portal.com',
});

const content = Content.Create({ Id: 123 }, ContentTypes.Task, repository);
store.dispatch(Actions.Delete(content, 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  'sn-redux';

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

Creating a store

import { Store } from  'sn-redux';
import { Repository } from 'sn-client-js';

let repository = new Repository.SnRepository({
  RepositoryUrl: 'http://path-to-your-portal.com',
});

const store = Store.configureStore(
    myRootReducer,
    myRootEpic,                   // If not set, the default will be 'Epics.rootEpic'
    [middleware1, middleware2],   // If not set, only the epicMiddleware will be used
    persistedState,               // Optional
    repository                    // Optional. If not provided, a Repository with default values will be used
    );

Using built-in actions

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

let repository = new Repository.SnRepository({
  RepositoryUrl: 'http://path-to-your-portal.com',
});

const parentPath = '/workspaces/Project/budapestprojectworkspace/tasks';
const content = Content.Create({
          DisplayName: 'My first task'
      }, ContentTypes.Task, repository);

dispatch(Actions.CreateContent(content))

Documentation

Influences

Example applications