I have this working. On receipt of a socket message, a value is emitted immediately and every second thereafter (incrementing the age), until socket received again.
However, I want it to emit every second regardless of whether socket has been received. So it would start off emitting every seconds, but when socket received the properties would change to the new ones and they would be emitted every second.
Can't quite figure out what to do.
updated: Observable<TargetDevice>; this.updated = socketService.onMessage.pipe( filter( message => message.messageType === SocketIoMessageType.Device && message.data.id === this.id ), map((message: SocketIoMessage) => <Device>message.data), tap(d => this.setProps(d)), switchMap(d => timer(0, 1000).pipe( tap(tick => (this.age = d.age + tick)), map(() => this) ) ) );