0

Does knockoutjs have a way to conditionally fire manual subscriptions?

According to docs I can use the notify extender to control when get notified of a changes in an observable, for example to always fire subscriptions like this: yourObservable.extend({ notify: 'always' });

What I want to know is if that is there a way to condition when to fire nofication not only with strings as above but with a custom predicate or some observable value like this: yourObservable.extend({ notify: myPredicateOrObservable });

Gxzzin
  • 119
  • 1
  • 8
  • I think you can write a custom extension that overwrites `notifySubscribers` like in [this answer](https://stackoverflow.com/a/17984353/3297291). Like Niemeyer states, I think it's probably a bad idea though. Could you clarify _why_ you want to do this? There might be other solutions to your problem. – user3297291 Feb 10 '21 at 08:25

1 Answers1

0

Are you looking for the yourObservable.valueHasMutated() function?

Sam
  • 1,634
  • 13
  • 21