Closed jamonholmgren closed 11 years ago
We may not want to do it in the will_appear
, as we would register the observer multiple times.
class SomeScreen < ProMotion::Screen
listen_for :an_event, action: :handle_an_event
def handle_an_event(args={})
# handle it
end
end
Perhaps like this?
You may want to make the listener conditional though. We can make it a hash which would only register it once even if called multiple times.
listen_for
sounds better than subscribe_to
-- good idea.
I would rather see smaller items like this left to the other two big frameworks, BubbleWrap & SugarCube, both of which already have this implementation.
On Dec 17, 2012, at 2:08 PM, Jamon Holmgren notifications@github.com wrote:
You may want to make the listener conditional though. We can make it a hash which would only register it once even if called multiple times.
— Reply to this email directly or view it on GitHub.
Good point. We definitely want ProMotion to tie in well with both of those frameworks. We'll look into their implementations and close this if they work well enough.
I like Sugarcube's implementation, but we won't force either on the user. I'll close this. Good suggestion, @macfanatic.
Let's add an abstraction to NSNotification (perhaps as a separate gem that integrates with ProMotion).
Example: