Start a new topic

An emerging design pattern

A few observations:

inputs are by default saved as state of the xap.inputs that are saved have no 'autotrigger' of their events


A use-case: I am making a visualization. I manually created dummy data and put it in the `data` input of my new vis. On page load, nothing happens due to #2 above. So what my development pattern does is to do the following.




OnPageLoad is a component whose `init` function calls its output.


My visualization's `trigger` port just calls `this.data()`.


What I think is worth discussing is: Why are we saving state if the state can't be used except passively? Why persist large datasets on data ports if the only way to actually call their handlers is to send the same data from elsewhere, or by using the component pattern that I show above?


I think we're currently in a weird state where we have the worst of both worlds: persisting state by default which causes quick bloat of xaps, and inability to effectively use this state without writing trigger ports whose only use is to call a method. Writing these triggers isn't always an option, however, in the case of standard components that I don't own.


The component will have the data in it's inputState of it's init method, do you not want to render then?

Ah, I hadn't thought of that. I think that would work. But it doesn't cover the use-case where I'm using someone else's component and want to auto-trigger (or not.)


For now, I'll just use the init, export the data, check if it exists and call the appropriate handlers. Thanks!

Login to post a comment