localvoid / liquid

[UNMAINTAINED] Library to build User Interfaces in Dart [Virtual DOM]
http://localvoid.github.io/liquid/
BSD 2-Clause "Simplified" License
29 stars 3 forks source link

Support MappedListIterable for building virtual DOM in build() #3

Closed tosh closed 9 years ago

tosh commented 9 years ago

I got a cryptic error message when I ported react-dart code over to liquid (see screenshot).

When I tried to use .map to build a list of children liquid complained. Converting the result of the mapping toList solved the problem.

causes error:

return root()(div(styles: style)(this.faces.map(
    (imageUrl) => face(key: imageUrl,
                                   imageUrl: imageUrl)))
);

solution:

return root()(div(styles: style)(this.faces.map(
    (imageUrl) => face(key: imageUrl,
                                   imageUrl: imageUrl)).toList())
);

screenshot 2014-12-05 21 48 55

Overall porting was a great experience as the liquid API feels way more like idiomatic Dart compared to React's JavaScript influenced API.

Is it possible to allow passing MappedListIterables?

localvoid commented 9 years ago

Yes, I'll add support for all Iterables.

I am not sure how inlining+dead code elimination works on this call() method right now, but it will be quite easy to implement transformer that will remove/inline unnecessary code in all cases that implemented inside of call().

And I hate this cryptic stack traces :) When I finish transformers, I'll start working on improving dev experience.

tosh commented 9 years ago

I have to say the DSL feels really great already. Even better than I imagined. My dart-react render methods were full of accesses to .props and .state and I either passed empty Maps or Maps that were cumbersome to write.

With liquid's call and named parameters everything became way more concise.