zrho / purescript-optic-ui

PureScript UI framework based on lenses.
122 stars 10 forks source link

Hide inline from public API #12

Closed FrigoEU closed 8 years ago

FrigoEU commented 8 years ago

Hey,

The "inline" function from OpticUI.Core is being used in the OpticUI.Components.Async module, to good effect. However it's also exposed in the public API and I feel it's a bit dangerous. I just spent a good amount of time tracking down a bug that was caused by it: I used it to (asynchroneously) load a resource when I try to render a UI component that needs it but it's not there yet. This resulted in calling the "step" function in OpticUI.Run while it was still running, and needless to say it trampled all over the VTree's.

I solved this now by adding a timeout of 0 milliseconds so the first step function has a chance to finish, update the references correctly, etc, before the second one comes in. I'm not sure that's the best way to solve this, but we'll see, it works for now. It adds another (together with REF) "strange" effect to my row of effects though, but I can live with that for now.

Simon

zrho commented 8 years ago

I would like to keep this functionality accessible since it is neccessary for some things (like async, but who knows what else can only be done with it), but you are right, it is unsafe. In an early draft I already marked it as such in documentation, but that seems not to have made it into the version I then committed. The best option, I think, would be to rename it to unsafeInline so it is clear that you have to be extra careful if you use it.

zrho commented 8 years ago

Inline is now gone, as it isn't required anymore.