Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

The call operator #6

Closed
wxnet2013 opened this issue Nov 8, 2018 · 0 comments
Closed

The call operator #6

wxnet2013 opened this issue Nov 8, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@wxnet2013
Copy link
Member

wxnet2013 commented Nov 8, 2018

import rxloop, { call } from '@rxloop/core';
import { map } from 'rxjs/operators';

const counter = {
  name: 'counter',
  state: 0,
  reducers: {
    increment(state) {
      return {
        ...state,
        counter: state.counter + 1
      };
    },
  },
  epics: {
    getData(action$) {
      return action$.pipe(
        call(async (action) => {
          return {};
        }),
        map((data) => {
          return {
            data,
            type: 'increment',
          };
        }),
      );
    }
  },
};

store.model(counter);

store.stream('counter').subscribe((state) => {
  if (state.error) {
    console.log( state.error.epic );
    return;
  }
  // setState(state);
});
@wxnet2013 wxnet2013 changed the title the request oprator the request operator Nov 8, 2018
@wxnet2013 wxnet2013 changed the title the request operator The process operator Nov 8, 2018
@wxnet2013 wxnet2013 added the enhancement New feature or request label Nov 8, 2018
@wxnet2013 wxnet2013 changed the title The process operator The call operator Nov 10, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant