Emitting using socket in LB4 from the repository #7667
Unanswered
siddharthmutkekar
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I need some help in socket programming using LB4. The requirement is to emit an event whenever there is an add/update in one db table. so i want to emit a message once the table is updated in the repository. So I am trying to do this in "after save" operation hook in the repository. I followed the socket example - https://github.com/alexkander/loopback4-example-websocket-app. This application is emitting the messages in the controller (API hits). But my case is, emitting an event from the repository because the requirement is to emit a message once any record is added or updated in the DB table. I tried injecting chat controller in my repository class and tried calling the method of chat controller which does the emit. But in chat controller method (handleChatMessage) the nsp (namespace) is shown as undefined. So the messages are not emitted.
Any help on this please ?
Thanks,
Siddharth
Beta Was this translation helpful? Give feedback.
All reactions