Skip to content

Instantly share code, notes, and snippets.

@cdbattags
Last active August 2, 2019 19:24
Show Gist options
  • Save cdbattags/48a5a8f3f0a4a27f7e97a03e62d74f2e to your computer and use it in GitHub Desktop.
Save cdbattags/48a5a8f3f0a4a27f7e97a03e62d74f2e to your computer and use it in GitHub Desktop.

Revisions

  1. cdbattags revised this gist Aug 2, 2019. 1 changed file with 0 additions and 13 deletions.
    13 changes: 0 additions & 13 deletions angular-redux-middleware.js
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,3 @@
    const middleware = function(store){
    return function(next){
    return function(action){
    // some async code
    action.payload = {
    data: asyncResponse
    };

    next(action)
    }
    }
    }

    // or using ES6 arrow functions
    const middleware = store => next => action => {
    next(action);
  2. cdbattags revised this gist Aug 2, 2019. 1 changed file with 17 additions and 0 deletions.
    17 changes: 17 additions & 0 deletions angular-redux-middleware.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    const middleware = function(store){
    return function(next){
    return function(action){
    // some async code
    action.payload = {
    data: asyncResponse
    };

    next(action)
    }
    }
    }

    // or using ES6 arrow functions
    const middleware = store => next => action => {
    next(action);
    };
  3. cdbattags revised this gist Aug 2, 2019. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions angular-redux-enhancer.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    import myStore from '../shared/store'; // initial store setup using plain Redux

    function storeProviderEnhancer() {
    return () => myStore;
    }

    // ... in AngularJS
    $ngReduxProvider.createStoreWith(state => state, [], [storeProviderEnhancer]);

    // ... in Angular using angular-redux/store
    this.ngRedux.provideStore(store as Store<IAppState>);
  4. cdbattags revised this gist Aug 2, 2019. No changes.
  5. cdbattags created this gist Aug 2, 2019.
    48 changes: 48 additions & 0 deletions angular-app.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    import angular from 'angular';
    import uiRouter from 'angular-ui-router';
    import ngRedux from 'ng-redux';

    import AppComponent from './app.component';

    import NavigationComponent from './components/navigation/navigation';
    import HomeComponent from './containers/home/home';

    // import the root reducer from reducers folder
    import { RootReducer } from './reducers';

    // import our default styles for the whole application
    import 'normalize.css';
    import 'bootstrap/dist/css/bootstrap.css';

    angular
    .module('app', [
    uiRouter,
    ngRedux,

    NavigationComponent.name,
    HomeComponent.name
    ])
    .config(($locationProvider, $stateProvider, $urlRouterProvider, $ngReduxProvider) => {
    "ngInject";

    // Define our app routing, we will keep our layout inside the app component
    // The layout route will be abstract and it will hold all of our app views
    $stateProvider
    .state('app', {
    url: '',
    abstract: true,
    template: '<app></app>'
    })

    // Dashboard page to contain our goats list page
    .state('app.home', {
    url: '/home',
    template: '<home></home>'
    });

    $urlRouterProvider.otherwise('/home');

    // create the root store using ng-redux
    $ngReduxProvider.createStoreWith(RootReducer);
    })
    .component('app', AppComponent);