Named handlers for SDLx::Controller #197

Closed
kthakore opened this Issue Jul 26, 2011 · 3 comments

Comments

Projects
None yet
3 participants
@kthakore
Member

kthakore commented Jul 26, 2011

What about get names for all handlers? For example:

$app->add_move_handler(player => sub{...});
$app->add_move_handler(unit1 => sub{...});
$app->add_move_handler(unit2 => sub{...});

...

$app->remove_move_handler('unit1');

It`s get more flexible behavior. Not need store indexes and use them, just use name what you set and you known.

To do:

  • Replace handlers array to hash
  • For save current behavior: set number as key for handler if key not specified

What do you think about that?

@ghost ghost assigned kthakore Jul 26, 2011

@Blaizer

This comment has been minimized.

Show comment
Hide comment
@Blaizer

Blaizer Aug 8, 2011

Member

Handlers need to be called in order. Hashes aren't ordered.

Member

Blaizer commented Aug 8, 2011

Handlers need to be called in order. Hashes aren't ordered.

@jtpalmer

This comment has been minimized.

Show comment
Hide comment
@jtpalmer

jtpalmer Aug 8, 2011

Member

Use an array of pairs (arrays) then. Fall back to a number when no name is specified.

Member

jtpalmer commented Aug 8, 2011

Use an array of pairs (arrays) then. Fall back to a number when no name is specified.

@Blaizer

This comment has been minimized.

Show comment
Hide comment
@Blaizer

Blaizer Aug 11, 2011

Member

Would be a much better idea to use an ordered hash module from cpan... but then that's another dependency.

Member

Blaizer commented Aug 11, 2011

Would be a much better idea to use an ordered hash module from cpan... but then that's another dependency.

@Blaizer Blaizer closed this Mar 25, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment