Unsubscribe live query in OrientJS

73 Views Asked by At

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.

1

There are 1 best solutions below

0
mitchken On BEST ANSWER

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.