-->

pubnub isTyping status Ionic2

2019-06-27 09:57发布

问题:

I've implemented a chat using Ionic2 with pubnub, the thing is how can I implement the isTyping to show it on my html? I know I have to create a state on my user, but I don't know how to update it.

My pubnub service have differents methods, and I thought I could add a PubNubEventType that it's called TYPING but I don't know how to update it from my component (where I have the chat implemented)

This is my component...

Any ideas?

回答1:

PubNub - using setState for isTyping

You just need to capture key press event to set state true and after a few seconds of no key press events or after publish (send button click), set state false. You set the state using this. pubNubService.setState(...) API.

The key press events part is purely JS/Iconic and not PubNub specific so I will leave that to someone else to provide insights.

This is an older blog but it demonstrates this very well.