"when" support - a slightly different take on #209

This is just to have both takes as PRs.

@phated can modify his code to reference what I have just in case this way is favored, or I can add documentation and remove [WIP] message.

See tests for usage (different types of usage).