Closed twavv closed 5 years ago
Ok, I think we figured out the fundamental purpose of Scope
from this discussion:
it's a carrier for the handlers for observables. Without an observable being associated with a scope, you have to have onjs(ob, jsexpr)
do one of these two weird things:
@js
As long as we don't want both of these, we need it to be associated with a "thing" so that we can serialize the handler when we serialize the "thing", and set it as a handler when we "render" the thing. This "thing" is scope.
Node
(Scope just forwards it to its .dom
to allow a consistent API).scope["foo"] = o
we can have o
be anything, and this is purely a dictionary now.
2) require a scope argument to onjs
which clearly states which scope serializes the handler. So instead of onjs(o, @js...)
you'd need to write onjs(o, scope, @js...)
.I'd be happy with this route. It seems like we'd want something like
WebIOWidget <: AbstractWidget
but I think @piever is holdingWidget
close to their chest.
The expression definitely made me smile :)
Somehow I like to think of AbstractWidget
as something in general not related to web things but more of a general building block for GUIs: it is an ordered collection of components, with instructions on how to layout them and an output. The specific Widget
implementation (even though it has scope
as one of the fields as it made implementing Interact much easier) is in theory reasonably independent of WebIO
. However if the new scope implementation has components, instruction on the layout of those components and an output it can definitely be a WebIOWidget <: AbstractWidget
. When I wrote Widgets it was not the case so at the time I felt it was two distinct concepts.
@shashi Continuing our conversation here about scopes specifically.
I kind of agree but also, at this point, a scope is just a wrapper around a dom element. A component can just as easily be identified by the top-level dom element without a separate type.
We could also do this with something like a
WebIO.Ref
object.The complication with this is garbage collection, though, which I will admit is easier-done with the scopes. Though I do think having refs like this would be a good feature though (maybe we could tie them to the lifespan of a scope). This might be out of scope (ahahaha puns!) for this issue.
I do think that could be cool though.
The other way we could try to track lifecycles is some magic with
@js_str
but seems less than ideal.I'm not really sure what you're saying. I think dissociating scopes and observables would overall be a good thing, especially to reduce the complexity of synchronizing between different scopes.
I'd be happy with this route. It seems like we'd want something like
WebIOWidget <: AbstractWidget
but I think @piever is holdingWidget
close to their chest.