Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Don't trigger changes if nothing was actually changed #64

Closed
maxpain opened this issue Nov 28, 2016 · 12 comments
Closed

Don't trigger changes if nothing was actually changed #64

maxpain opened this issue Nov 28, 2016 · 12 comments

Comments

@maxpain
Copy link
Contributor

maxpain commented Nov 28, 2016

oldDoc not passing

Items.find().observe({
  changed(newDoc, oldDoc) {
    console.log(newDoc, oldDoc) // { foo: "bar" } undefined
  }
})

It's possbile fix it?

@theodorDiaconu
Copy link
Contributor

@Maxpain177 good find. yes it will be fixed.

@theodorDiaconu
Copy link
Contributor

@Maxpain177 a lot of changes are currently required to do such a thing. Basically the current observe() is not a full implementation of the observe() which has support for addedBefore, etc.

Do you really need this functionality ? This is my question. Because if there is no way to work-around this in some scenarios we will implement it.

@maxpain
Copy link
Contributor Author

maxpain commented Nov 29, 2016

@theodorDiaconu Yes, In my project (which contains several microservices, connected to one mongodb and redis) it is using everywhere.

@theodorDiaconu
Copy link
Contributor

@Maxpain177 I understand. Redis-oplog is now ready to go under some restructuring and refactoring, and this will be included :)

@maxpain
Copy link
Contributor Author

maxpain commented Nov 29, 2016

@theodorDiaconu, Currently, i can't use this package, because i need remake most part of application architecture for working without oldDoc.
Thanks 👍

@theodorDiaconu
Copy link
Contributor

@Maxpain177 check it now :)

@maxpain
Copy link
Contributor Author

maxpain commented Dec 2, 2016

@theodorDiaconu Yes, it works. But, if nothing changed in doc, changed function still fires.

@theodorDiaconu
Copy link
Contributor

@Maxpain177 can you give me an example ? What kind of update you do ?

@maxpain
Copy link
Contributor Author

maxpain commented Dec 2, 2016

@theodorDiaconu
Just updating document.

Counts.update({ _id: "users" }, { $set: { count: 0 } })

@theodorDiaconu
Copy link
Contributor

@maxnowack so if "count" was previously ZERO, it should not fire the change event.

@theodorDiaconu theodorDiaconu changed the title Observe oldDoc support? Don't trigger changes if nothing was actually changed Dec 2, 2016
@theodorDiaconu theodorDiaconu reopened this Dec 2, 2016
@maxpain
Copy link
Contributor Author

maxpain commented Dec 2, 2016

@theodorDiaconu, Reproduction

@theodorDiaconu
Copy link
Contributor

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants