Just one use case: say you have two Models Artist and Album.
Updated Album data arrives with nested artist data, and you want artist data (artist attribute) be converted into Artist instance.
Using attributes plugin you do:
- var Artist = can.Model({..})
- var Album = can.Model({
- attributes: {
- artist: 'Artist'
- },
- convert: {
- Artist: function(val){return Artist.model(val)}
- }
- },{
- })
at first glance instead of
- return Artist.model(val)
you could do just:
- return new Artist(val)
But the the problem is that new Artist(val) will just replace artist attribute with new instance (new _cid) and replace instance in Artist.store. If you prefer to keep working with exiting instance you want to use Artist.model(val)