0.1.4 • Published 7 years ago

angular-redux-bindings v0.1.4

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

Angular redux bindings

Bind redux state to your AngularJs controller

Minimal module to bind your Redux state to your Angular controller, see usage below. This module is in a very early stage of development and may change drastic.

Install

$ npm install --save angular-redux-bindings

Usage

import angular from 'angular';
import logger from 'redux-logger';
import 'angular-redux-bindings';

const firstReducer = (state = { api: 'https://google.com' }, action) => {
    switch (action.type) {
        case 'TESTY':
            return {
                ...state,
                api: 'http://my-api-dir.se'
            }
        default:
            return state;
    }
};

angular.module('app', ['angularReduxBindings'])
    .config(['$angularReduxProvider', function ($angularReduxProvider) {
        $angularReduxProvider.createStore({
            firstReducer
        }, [logger]);
    }])

    .controller('PageController', ['$scope', '$angularRedux', function ($scope, $angularRedux) {
        const unsubscribe = $angularRedux.bindState(state => {
            return {
                api: state.firstReducer.api
            };
        }, this);

        $scope.handleClick = () => {
            $angularRedux.dispatch({ type: 'TESTY' });
        };

        $scope.$on('$destroy', unsubscribe);
    }]);

Author

Patrik Höggren, p at hoggren.nu

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago