Skip to content

Observing changes in component #100

@Nighthawk14

Description

@Nighthawk14

Hi all, I'd like some implementation advices please :).

So let's say that I have this basic implementation:

constructor($ngRedux, $scope) {
    let unsubscribe = $ngRedux.connect(this.mapThisToState)(this);

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

  mapThisToState(state) {
    return {
      error: state.error
    };
  }

How can I do to watch for changes on the error object from the state. I know that the mapThisToState method is triggered every time the state changes but is it a good practice to add logic in it like:

mapThisToState(state) {
    if(state.error === 'error') { this.doSomeStuff(); }
    return {
      error: state.error
    };
  }

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions