MVCoconut / coconut.data

Observable Data Layer.
The Unlicense
20 stars 8 forks source link

Feature request: spread #72

Closed serjek closed 3 years ago

serjek commented 3 years ago

Allow spread model into another model like it is now possible with model to view spread. Like so:

class Parent implements Model {
  @:computed var prop:String;
// long list of props
  @:computed var child:ChildModel = new ChildModel({...this, someExcludedProp: 'excluded'});
}
Neverbirth commented 3 years ago

AFAIK the problem is that this would require changes on compiler side to allow for this syntax. You can simulate this by using tink.Anon.merge, it is maybe less "exciting" to read, but does the work, and it is what "..." in coconut views uses behind.

serjek commented 3 years ago

yeah that's how I do it now, with tink.Anon.merge, so I just thought it would be nice to have same spread syntax across all coconut.

back2dos commented 3 years ago

Yeah, the best we can do right now is merge(this, someExludedProp = 'excluded') if you import tink.Anon.merge; FWIW it does have a lower token count ;)

Related: https://github.com/HaxeFoundation/haxe/issues/7234