I have been neck deep for some time using and benefiting from the ko.mapping extension and have developed some pretty complicated nested objects. When Sanderson recently posted the blog on the new knockout projections library I raised a brow on how I might revisit some of my problems to benefit. As stated, the projections library uses Knockout 3.0's arrayChange abilities to create more solid relationships with arrays, reducing the extra overhead when we subscribe to changes on observableArrays.
What I am attempting to do now is take this new library and improve my models. Some of my relationships have nested relationships that are often circular, so I have to employ 'deferEvaluation' on a few instances just to get them initialized before they all go nuts and start running against one another.
I started using the basic map capabilities, such as
self.Workshifts = self.WorkshiftsData.map(function(ws) {
return new ScheduleWorkshift(ws);
});
and in other cases the filter
newWSE.Workshifts = self.WorkshiftsData.filter(function(ws) {
return ws.Key == wse.WorkshiftKey;
});
However there is still the big problem with some of the more complex properties needing to defer their initialization until the whole model is loaded...it's really a chicken before the egg problem.
I know it's all new, which is why I think I'm the first to post a question on this tag. I'd like some more information on this and where you may use it to leverage it's true power.
My question, though, for those brave souls with a knack for good explanations, is
'How can I use chaining with a combination of maps and filters and what would be a good situation where I'd really need to do this? What would my resulting object be capable of?'
Cheers...
ps...I don't have a rep of 1500+ and would like someone to create and add the tag 'knockout-projections' to this question and kick it off...