Dynamic subscriptions on server events

This is because Drab is a kind of interoperability stuff between browser and server.

I’ve been thinking about casting everything as string, it would be easier to implement, but we would loose quite essential information about the type.

Now, you can pass the argument to the handler as any valid, JSONable javascript, so if you do drab-click="subscribe_market([1, 2, 3])" you’ll get an Elixir list in you handler.

Vice versa, if you set the object property with set_prop(socket, "#myelem", property: [1, 2, 3]) you expect that document.getElementById("myelem").property == [1, 2, 3]. An array, not a string “[1,2,3]”.

That was my understanding when I implement this.

3 Likes