Posts from 4 February 2015
-
One of my hangups about continuing work resolved itself over the past couple days. I ended up having a couple of redundant checkins—"Fixes data model", "Data model finally fixed"—but I think I'm there now.
Collections have models, and certain models, like
Posts
, have collections of their own (in this case, comments). When you pull the data from the server for a non-root page, the data needs somewhere to "hang" so as not to face sync problems. So, when I fetch a post, I shouldn't fetch the class it belongs to, I should instead examine the post's section_id property, and then put that in an existing class's post collection. … Got it?User -> Sections Collection -> Section Model -> Posts Collection -> Post Model
So, on fetch of the last item in that chain, I need to go to the head of the chain and request that this data goes in the proper place in that chain.
It took me a while, but I think I ironed out all the kinks. It took moving some logic from the models into the collections: if you ask a
Post
what section (class) it belongs to, it asks its collection, which in turn had that property set upon initialization. (I also needed to start initializing new collections with(null, options)
instead of({}, options)
because it turns out{}
is a model on its own, just one with no attributes… derp.)What does this mean? A whole bunch of crazy sync problems disappeared all at once, and I can finally see the light at the end of the tunnel. I have never truly had a Minimum Viable Project (MVP), and I'm getting to the point where that feels possible, and likely to happen soon.