aleclarson / emitter-kit

Type-safe event handling for Swift
MIT License
567 stars 71 forks source link

Event Listners Count always return 0 despite of adding listners #52

Closed ghost closed 6 years ago

ghost commented 6 years ago

        signInEvent = Event<MasterViewController>()

        //button touchup inside event
        btnSignIn.onTap { [weak self] in
            if self == nil {
                return
            }
            self?.signInEvent?.emit(SigninController()) //Emit data Here
            print(self?.signInEvent?.listenerCount) //Always return 0
        }

        //Listner
        let listner = signInEvent?.on({ (data) in
            print(data)
        })
aleclarson commented 6 years ago

Hello! What version of Swift and EmitterKit are you using?

aleclarson commented 6 years ago

Are you forgetting to retain your signInEvent listener?

If so, this is a duplicate of #27. Please confirm. :)

PS: The listenerCount property is deprecated. You should use getListeners().count if you want to know how many listeners exist that have no target. I may consider adding countListeners(target) and countAllListeners() methods if lots of people want them.