SwiftKickMobile / SwiftMessages

A very flexible message bar for UIKit and SwiftUI.
MIT License
7.24k stars 741 forks source link

EventListeners not called ? #536

Closed jerometonnelier closed 7 months ago

jerometonnelier commented 7 months ago

Hi!

I use SwiftMessages from ages now, and I recently found that eventListeners are not called anymore (at least on my project). I added them the way they should :

conf.eventListener.append { [weak self] (event) in
            guard let self = self else { return }
            switch event {
            case .willHide: // do whatever I need
            case .willShow: // do whatever I need
            default: ()
            }
        }
// ...
SwiftMessages.show(config: conf, view: view)

I never enter the completion block now :-/ Anyone has this issue ?

Thanks

wtmoose commented 7 months ago

It is working for me. I attached a test project that logs events to the console. Is there any chance that self == nil and you're exiting on the guard? If not, I'll need some help with reproducing.

SwiftMessagesTest.zip

jerometonnelier commented 7 months ago

Hi and thanks for your answer. The test projects works too. I actually have the issue with a custom XIB file, maybe it's a part of the issue ? class AlertMessageView: MessageView {...}

wtmoose commented 7 months ago

No, that wouldn't have anything to do with it. My suggestion is put a break point in Presenter.swift in the function func show(completion: @escaping AnimationCompletion) throws. Step through it and see what's going on.

jerometonnelier commented 7 months ago

My bad, I do enter the eventListener, but for some reason, I can't put a breakpoint inside 🤔. If I put a simple print it works! I will close it, sorry for the inconvenience

wtmoose commented 7 months ago

No problem. Glad it’s working