Default rule for named properties

4 views
Skip to first unread message

Nek

unread,
Oct 5, 2009, 9:56:33 AM10/5/09
to Smartypants IOC
Hi!
I've got a feature idea I want to discuss.

Here is my code:
SmartyPants.whenAskedFor(ICommand).named("stream_started").useValue
(new Command(this,started));
SmartyPants.whenAskedFor(ICommand).named("stream_stopped").useValue
(new Command(this,playNext));
SmartyPants.whenAskedFor(ICommand).named("stream_not_found").useValue
(new Command(this, skip));
SmartyPants.whenAskedFor(ICommand).useValue(new NullCommand());

There are some more named properties and I'm trying to use the last
line to set all named ICommand props I don't want to set explicitly to
some default value.
Of course I've got an error:
Error: Could not inject dependencies into an instance of
com.nikitadudnik.minivideoplayer.model::Playlist because of Error:
There is no injector rule for a
com.nikitadudnik.minivideoplayer.events::ICommand named
"playlist_parse_error"

The simple solution is to change injector behaviour to the one I've
expected.
The harder but maybe much more useful solution is to add some pattern
recognition (wildcard or regexp) to the .named('someName') rule.

What do you think?

Josh McDonald

unread,
Oct 5, 2009, 8:43:02 PM10/5/09
to smartyp...@googlegroups.com
There's an undocumented (and untested IIRC) wildcard, named "*" at the moment, but I'm not sure it'd do what you want. I've been thinking we might want a "smarter" Provider interface that receives some useful information on getInstance(). This would be required as part of the "solve robot-legs problem" feature. Which now needs a new name, dammit :)

Thoughts?

-Josh

2009/10/5 Nek <nikd...@gmail.com>



--
"Therefore, send not to know For whom the bell tolls. It tolls for thee."

Josh 'G-Funk' McDonald
  -  jo...@joshmcdonald.info
  -  http://twitter.com/sophistifunk
  -  http://flex.joshmcdonald.info/

Nikita Dudnik

unread,
Oct 7, 2009, 2:23:47 PM10/7/09
to smartyp...@googlegroups.com
I think it's all about nice syntax. The reason I use SmartyPants except it's weight is it's request rules DSL.
So got to see the syntax proposal.
And I consider myself not experienced enough to make one.
Saying the truth I've met robot legs problem only in theory though I can easily imaging bumping into it in practice.

And getting back to practice the undocumented wildcard actually could solve my case.
I'll test it later.

Thanks!
Reply all
Reply to author
Forward
0 new messages