我需要一个Observable来订阅我的Rx.Obervable.webSocket连接时。我可以使用openObserver属性,但我不知道如何创建一个Observalbe。
const WebSocket = require('ws');
const Rx = require('rxjs');
const observer = {
next: (event) => {
console.log('Test');
}
}
const socket = Rx.Observable.webSocket({
url: 'ws://192.168.100.155:2001',
WebSocketCtor: WebSocket,
openObserver: observer,
protocol: 'server'
});
isConnected().subscribe(() => {
// do something after socket is connected ...
});
答案 0 :(得分:1)
我想你可以这样做:
/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new \App\Notifications\MyResetPasswordNotification($token));
}
这应该在建立连接时首先向主题发出一个值,然后发出每条消息。