-
Notifications
You must be signed in to change notification settings - Fork 412
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
Transformed documents are non-reactive #667
Comments
I have created a project that reproduces / better explains the issue I am having. https://github.com/lewislambert/Iron-Router-Issue-667 |
Hey @lewislambert - thanks for the reproduction. I am seeing the issue you've outlined and it's not immediately obvious why. I'll have to trace through to try and figure out what's going on. |
OK, I worked out what the problem is. The issue is kind of complicated, but I'll do my best to explain:
In the case of changing it on the commandline, we don't see this behaviour, because it's a different in-memory object that you modify and then save. I'm not really sure what the solution to this problem is. I fear that your approach of modifying the document and then saving it will trigger this kind of problem around the place in Meteor (as UI makes extensive use of emboxing). @ryw - have you guys experienced this issue with minimongoid (which I assume does something similar to this?) |
Hi. Thanks for the update and I'm glad to hear it wasn't just me doing things the 'wrong way'. I certainly had trouble figuring it out as it was frustrating that it worked from the console no problems. Now I know where the problem is, I'll try and find a workaround until the bug is fixed. Thanks |
@lewislambert - I guess what I was trying to tell you is that I think you might find you have problems around the place with Meteor and this technique. I don't think it's "wrong" by any means, but I don't really see a "bug" in IR that is going to be "fixed" to solve this for you. |
@tmeasday OK thanks for that. So assuming then that I should stick with the standard meteor collections approach, have you any ideas how I might be able to still simplify a lot of collection logic by abstracting out into Models? I've got quite a lot of collections in a project I am working on and I thought as there isn't really a good abstraction layer for Models out there (some but none really completed/fully functional) I could kill two birds with one stone. Now I'm thinking it may not be a good idea. |
@lewislambert - we use models all over the place, but we just don't go to the point of implementing a Again, not to say that there's anything wrong with that. This is why I'm intrigued about whether those who are using minimongoid have seen this kind of issue before -- @ryw @queso ? |
If you look at save on minimongoid, it just wraps update to have minimongo syntax like _id, {$set:}, etc. Minimongoid doesn't go so far as to implement much new, just handy wrapped up methods. |
Hmm. I would think this could lead to the same scenario -- where a record is modified "in-place", then saved to the the db, triggering emboxed I should make a simple reproduction of this with a |
OK. I realised it's not embox, but us. I've opened a new ticket which should make it all clearer for us. Thanks @lewislambert |
Yes my model class (not in full above) is also just a wrapper for the Collections insert/update but with diffing so that only changed attributes are updated, arrays are pushed/pulled etc which is why I couldn't understand the issue. Relieved it's not just me! |
I've been working on a very basic (work in progress) Model class for a project I am working on which seems to work fine with Iron Router, but I'm having a bit of an issue with reactivity once the model is updated.
For example, when declaring a route with my data function returning a Model using findOne on my collection, the data source works fine and everything is displayed on screen as expected, until that is, I call
save
on my model after updating some properties. At this point, there is no reactive update. However, if I call the same methods to update the model from the console, everything updates.model.js
and in my routes setup I have the following
Collections.Wiki
is essentially returned fromcreateModel
as above. So the data returned fromfindOne
is an instance of the model. Now somewhere in my template event handlers I update a property, call save and nothing happens unless I do a manual refresh. Whereas when using the same code in the JS console of the browser, it updates fine.Has anyone else come across this issue at all?
The text was updated successfully, but these errors were encountered: