Add scoped function

Add a function to handle the common enter-leave pattern.
Oh right, I'ev reviewed it too quickly.

Please remove the "This is syntactic sugar for" section in the comment - no need to duplicate the code there.
An usage example would be more helpful.