Closed corranwebster closed 4 years ago
Observation Mini-Language
:+1: to simplify the mini-language so that it is easier to understand. I often find myself reading the documentation again and again (even for this comment).
I am wondering if we could spell out the logic as expressions so we don't need to learn the difference between .
and :
, []
vs ()
or whether "items"
has special meanings etc. e.g.:
on_trait_change("name")
-> observe("name")
or observe(trait("name"))
on_trait_change("container, container[]")
-> observe(one_of("container", trait("container").elements))
on_trait_change("container[]")
-> observe(trait("container").elements)
on_trait_change("container_items")
-> observe(trait("container").elements)
on_trait_change("container:attr")
-> observe(trait("container").elements.trait("attr"))
on_trait_change("[container,name]")
-> observe(one_of("container", "name"))
on_trait_change("foo.container_items")
-> observe(one_of("foo", trait("foo").trait("container").elements))
on_trait_change("[foo,foo2].name")
-> observe(one_of("foo", "foo2", trait("foo").trait("name"), trait("foo2").trait("name")))
on_trait_change("foo.+name")
-> observe(one_of("foo", trait("foo").all_traits().has_metadata("name"))
on_trait_change("prefix+")
-> observe(all_traits().startswith("prefix"))
on_trait_change("foo:prefix+")
-> observe(trait("foo").all_traits().startswith("prefix"))
on_trait_change("([left,right]).name*")
-> observe(one_of("name", trait("left").trait("name", any_level=True), trait("right").trait("name", any_level=True)))
For wide matches, the expression looks more verbose. But this is to me more readable, possibly more extensible too?
Are we adding unobserve
like traitlets? Or are we keeping the remove=True/False
flag?
I think we should be keeping the remove
flag for now, although that's not incompatible with having an unobserve
if we want. I guess if we want the keyword arguments for something else then unobserve
might make sense.
now that #24 has been merged, can we close this issue?
We kinda failed to follow the process on this one (as we're also failing to do on EEP 5) - what's supposed to happen is a sequence of discussion-acceptance-implementation. We should either revise the process or make an effort to follow it.
Anyway, yes, let's close.
This is an issue for discussing issues around the EEP 3 proposal.