Giter VIP home page Giter VIP logo

sn-redux's Introduction

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.