enthought / ets

ets.py is a utility to clone and manage various Enthought Tool Suite packages
http://docs.enthought.com/ets
Other
34 stars 11 forks source link

EEP 3 Discussion: Trait Observables #30

Closed corranwebster closed 4 years ago

corranwebster commented 4 years ago

This is an issue for discussing issues around the EEP 3 proposal.

kitchoi commented 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?

corranwebster commented 4 years ago

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.

rahulporuri commented 4 years ago

now that #24 has been merged, can we close this issue?

mdickinson commented 4 years ago

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.