Skip to content

Computed observables don't call read functions if the value was unchanged #2

@dangrasso

Description

@dangrasso

Hi, first of all thank you for this library, it's just what I was looking for!
I'm replacing knockout with observable.js in a large project and i found out that there is a difference in how computed observables work in the two libraries, which can lead to bugs.

Problem:
When i write a computedObservable with the same value it had before, not only subscribers are not called (that is expected), but also the 'read' and 'write' functions are not used. This is not the case for KO.
(Setting notify: 'always' does not seem to help)

To see it in action: http://jsfiddle.net/5z0r9qbq/

The example in the jsFiddle might seem unrealistic.
But imagine you are doing input validation/sanitization in the write function and storing the clean result somewhere else. The read function simply returns the clean result from there.

Now if we pass invalid data two times in a row, the second time our read function is ignored and what we get is the dirty input that has been implicitly stored.

Any idea/plan how to fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions