Skip to content

Inconsistency between afterLiveQueryEvent "type" and SDK #7022

Closed
@dblythy

Description

@dblythy

Is your feature request related to a problem? Please describe.

This is my fault, but basically, request.event in the afterLiveQueryEvent contains a first letter uppercase, where the JS SDK does not. E.g:

 Parse.Cloud.afterLiveQueryEvent('TestObject', req => {
      expect(req.event).toBe('Create');
});

vs

subscription.on('create', object => {});

This could be confusing and potentially lead to bugs. Infact, I even made the mistake for the docs:

Parse.Cloud.afterLiveQueryEvent('MyObject', async (request) => {
  if (request.event != "update") {
    request.sendEvent = false;
    return;
  }
  const object = request.object;
  const pointer = object.get("child");
  await pointer.fetch();
});

This example will never fire as .event is defined as:

let type;
if (isOriginalMatched && isCurrentMatched) {
   type = 'Update'; // 'Update', not 'update'
} else if (isOriginalMatched && !isCurrentMatched) {
   type = 'Leave';
} else if (!isOriginalMatched && isCurrentMatched) {
   if (originalParseObject) {
      type = 'Enter';
   } else {
      type = 'Create';
   }
} else {
   return null;
}

Describe the solution you'd like

Casing consistent across SDK and afterLiveQueryEvent, or at least documented that they are different.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions