subscribe(eventObj) {
    const NS = eventObj.NAMESPACE,
      calls = [],
      self = this;

    function invalidateAccess(event) {
      let data = event.payload,
        accessId = data.access_id || data.id;
      if (!accessId) return;
      self.invalidate({
        access_id: accessId
      });
      logger.trace(`Invalidation for access: ${accessId} created from UNLOQ event: ${event.type}`);
    }

    function invalidateUser(event) {
      let data = event.payload,
        accessId = data.access_id,
        userId = data.profile_id;
      if (!accessId || !userId) return;
      self.invalidate({
        access_id: accessId,
        user_id: userId
      });
      logger.trace(`Invalidation for user ${userId} in access: ${accessId} created from UNLOQ event: ${event.type}`);
    }

    calls.push(() => {
      return eventObj.subscribe(NS.IAM, [
        'access.update', 'access.delete',
        'access.type.update', 'access.type.delete',
        'category.update', 'category.delete',
        'entity.save', 'entity.delete',
        'entity.type.delete',
        'permission.save', 'permission.update', 'permission.delete',
        'role.update', 'role.delete'
      ], invalidateAccess);
    });

    calls.push(() => {
      return eventObj.subscribe(NS.IAM, [
        'access.user.grant', 'access.user.revoke'
      ], invalidateUser);
    })


    return thorin.series(calls);
  }
/**
   * Using unloq-events, we will listen for events from UNLOQ to invalidate.
   * */
Using unloq-events, we will listen for events from UNLOQ to invalidate.
Using unloq - events we will listen for events from UNLOQ to invalidate .
subscribe(eventObj) {
    const NS = eventObj.NAMESPACE,
      calls = [],
      self = this;
    function invalidateAccess(event) {
      let data = event.payload,
        accessId = data.access_id || data.id;
      if (!accessId) return;
      self.invalidate({
        access_id: accessId
      });
      logger.trace(`Invalidation for access: ${accessId} created from UNLOQ event: ${event.type}`);
    }
    function invalidateUser(event) {
      let data = event.payload,
        accessId = data.access_id,
        userId = data.profile_id;
      if (!accessId || !userId) return;
      self.invalidate({
        access_id: accessId,
        user_id: userId
      });
      logger.trace(`Invalidation for user ${userId} in access: ${accessId} created from UNLOQ event: ${event.type}`);
    }
    calls.push(() => {
      return eventObj.subscribe(NS.IAM, [
        'access.update', 'access.delete',
        'access.type.update', 'access.type.delete',
        'category.update', 'category.delete',
        'entity.save', 'entity.delete',
        'entity.type.delete',
        'permission.save', 'permission.update', 'permission.delete',
        'role.update', 'role.delete'
      ], invalidateAccess);
    });
    calls.push(() => {
      return eventObj.subscribe(NS.IAM, [
        'access.user.grant', 'access.user.revoke'
      ], invalidateUser);
    })
    return thorin.series(calls);
  }
subscribe ( eventObj ) { const NS = eventObj . NAMESPACE , calls = [ ] , self = this ; function invalidateAccess ( event ) { let data = event . payload , accessId = data . access_id || data . id ; if ( ! accessId ) return ; self . invalidate ( { access_id : accessId } ) ; logger . trace ( ` ${ accessId } ${ event . type } ` ) ; } function invalidateUser ( event ) { let data = event . payload , accessId = data . access_id , userId = data . profile_id ; if ( ! accessId || ! userId ) return ; self . invalidate ( { access_id : accessId , user_id : userId } ) ; logger . trace ( ` ${ userId } ${ accessId } ${ event . type } ` ) ; } calls . push ( ( ) => { return eventObj . subscribe ( NS . IAM , [ 'access.update' , 'access.delete' , 'access.type.update' , 'access.type.delete' , 'category.update' , 'category.delete' , 'entity.save' , 'entity.delete' , 'entity.type.delete' , 'permission.save' , 'permission.update' , 'permission.delete' , 'role.update' , 'role.delete' ] , invalidateAccess ) ; } ) ; calls . push ( ( ) => { return eventObj . subscribe ( NS . IAM , [ 'access.user.grant' , 'access.user.revoke' ] , invalidateUser ) ; } ) return thorin . series ( calls ) ; }
Using unloq-events, we will listen for events from UNLOQ to invalidate.
Using unloq - events we will listen for events from UNLOQ to invalidate .