orientdblivequeryorientjs

Unsubscribe live query in OrientJS


I use OrientJS with OrientDB to perform livequery. The subscription to live query has no problem but I could not find any way to unsubscribe from that event.


Solution

  • This will unsubscribe from the token which is returned on initializing the live query.

    live unsubscribe ${token}

    This token is acquired by using the returned data from the liveQuery resolver.

    db.liveQuery(QUERY, {
      resolver: (a, b) => {
        const token = _.first(a).token;
          return a;
      },
    })
    

    Please note that you have to include return a to not break the built-in resolver.