Observe file changes with node.js

后端 未结 3 752
栀梦
栀梦 2020-11-28 08:39

I have the following UseCase:

A creates a Chat and invites B and C - On the Server A creates a File. A, B and C writes messages into this file. A,

3条回答
  •  悲哀的现实
    2020-11-28 09:10

    I do not think you need to have observe file changes or use a NoSQL database for this (if you do not want to). My advice would be to look at events(Observer pattern). There are more than enough tutorials on this topic available online (Google). For example Felix's article about Using EventEmitters

    This publish/subcribe semantic can also be achieved with NoSQL. In Redis for example, I think you should have a look at pubsub.

    In MongoDB I think tailable cursors is what you are looking for. On their blog they have a post explaining pub/sub.

提交回复
热议问题