JuliaGizmos / Escher.jl

Composable Web UIs in Julia
https://juliagizmos.github.io/Escher.jl
Other
335 stars 63 forks source link

Easy rendering of subscriptions #180

Closed izaid closed 7 years ago

izaid commented 7 years ago

This PR adds a single line to Escher.jl: convert(::Type{Node}, sub::Subscription) = render(sub, Dict()). That line allows a Subscription to be used directly with << without a user having to call render on it directly.

I'd argue that this is useful, as some subscriptions can already be used with << -- see dropdownmenu, for instance. My motivation here was to make subscriptions in other packages, like ThreeJS.jl, easier.

This PR is ready for review / merging.

izaid commented 7 years ago

@shashi What do you think? Happy to merge this?

shashi commented 7 years ago

This seems like a special case. What about all the million other Tile types which can well be converted to Elems?

I think you should keep this in an @require Escher begin ... end inside ThreeJS or your application.

I think the deeper question here is do we need render at all? (Why not have all Escher functions just return Elems?) I'm trying to come up with a way to get rid of render, but it won't happen immediately.

izaid commented 7 years ago

Why do you need render at all right now? For intents and subscriptions?

shashi commented 7 years ago

Yes. More generally, for dispatch on Tile types, for example, wrapbehavior takes a ton of different Tile types and gives back Behavior tiles.

if we do away with render, we need to be able to parameterize Elems by arbitrary types so that this ability can be retained, (the terrible) Elem{ns, tag} should really be Elem{T} where T is anything for users of Patchwork to use.

Edit: see https://github.com/shashi/Patchwork.jl/tree/next