davidstump / SwiftPhoenixClient

Connect your Phoenix and iOS applications through WebSockets!
MIT License
507 stars 147 forks source link

[feature request] Timeout Callback #201

Closed morgz closed 2 years ago

morgz commented 2 years ago

This library is brilliant. Thanks for all your hard work.

I was wondering. On a push timeout, would it be possible to be notified by callback

Something like this:

        self.channel?
            .push("next_turn", payload: [:])
            .receive("ok", callback: { [weak self] message in
                print("\n -- Next Turn Successfull -- \n")
                self?.nextTurnRemoteOperation = .success
            })
            .timeout({
                //
            })
dsrees commented 2 years ago

Thanks, glad you enjoy using it

You should be able to use something like

.receive("timeout", callback: ... })
morgz commented 2 years ago

Brilliant. Thanks!