This repository was archived by the owner on Oct 19, 2018. It is now read-only.
This repository was archived by the owner on Oct 19, 2018. It is now read-only.
while_loading / on_error redo #251
Open
Description
currently .while_loading
is attached to a component like this:
Component(p1: exp1) do
... render some stuff
end
.while_loading do
... render this stuff if loading
end
Now that React 16 (and Hyperloop 1.0) have error handling it would be nice to extend this syntax like this:
Component(p1: exp1) do
...
end
.while_loading do
...
end
.rescue do # yes handily enough that is legal syntax
...
end
but in order for this to work there is a vast amount of trickery inside of Hyper-React and Hyper-Mesh.
Everything can be greatly simplified if we create a wrapper Psuedo component, and just reuse the existing event handler mechanism:
Try do
....render some stuff
end
.on(:loading) do
...replace with this if loading
.on(:exception) do |e|
...replace with this if an error occurs (or re-raise e)
end
# user is an active record model instance
... LI { Try { user.name }.on(:loading) { IMG {src: 'spinner.gif' } } }
Try { DisplayThing(thing: some_thing) }
.on(:exception) { |e| DIV { "some thing is wrong" } }
I am proposing using the .on(...) syntax for a couple of reasons:
- less syntax to learn
- everything can be explained in terms of existing constructs
- everything can be built on top of existing hyper-loop without messing with internals
Note that the current 1.0.0 (edge) error handling call back (as defined by @janbiedermann ) would remain and can still be used, and would in fact be the basis for implementing the above.
Metadata
Metadata
Assignees
Labels
No labels