Push
public class Push
-
The channel sending the Push
Declaration
Swift
public weak var channel: Channel?
-
The event, for example
phx_join
Declaration
Swift
public let event: String
-
The payload, for example [“user_id”: “abc123”]
Declaration
Swift
public var payload: Payload
-
The push timeout. Default is 10.0 seconds
Declaration
Swift
public var timeout: TimeInterval
-
Resets and sends the Push
Declaration
Swift
public func resend(_ timeout: TimeInterval = Defaults.timeoutInterval)
Parameters
timeout
Optional. The push timeout. Default is 10.0s
-
Sends the Push. If it has already timed out, then the call will be ignored and return early. Use
resend
in this case.Declaration
Swift
public func send()
-
Receive a specific event when sending an Outbound message. Subscribing to status events with this method does not guarantees no retain cycles. You should pass
weak self
in the capture list of the callback. You can call `.delegateReceive(status:, to:, callback:) and the library will handle it for you.Example:
channel .send(event:"custom", payload: ["body": "example"]) .receive("error") { [weak self] payload in print("Error: ", payload) }
Declaration
Swift
@discardableResult public func receive(_ status: String, callback: @escaping ((Message) -> ())) -> Push
Parameters
status
Status to receive
callback
Callback to fire when the status is recevied
-
Receive a specific event when sending an Outbound message. Automatically prevents retain cycles. See
manualReceive(status:, callback:)
if you want to handle this yourself.Example:
channel .send(event:"custom", payload: ["body": "example"]) .delegateReceive("error", to: self) { payload in print("Error: ", payload) }
Declaration
Swift
@discardableResult public func delegateReceive<Target: AnyObject>(_ status: String, to owner: Target, callback: @escaping ((Target, Message) -> ())) -> Push
Parameters
status
Status to receive
owner
The class that is calling .receive. Usually
self
callback
Callback to fire when the status is recevied