I followed all steps in documentation, but this function never gets called:
subscription.on(LiveQueryEvent.create,
(value) {});
All I receive in terminal is this: "ReSubScription:{}".
I am trying to capture the event when one of my classes in the database gets a new record/entry.
If requested, I can arrange a demo codebase, but please help me get through this.
PS: I am calling this subscription.on() method in initState() method of a stateful widget, not in main().
UPDATE
I am sharing link of git repo of a minimal app to demonstrate what I did. Here is the link
Please see what have I done incorrect with livequery. Would be grateful for any pointers/guidance.
UPDATE 2nd
Please note, I've hardcoded adminId (objectId of admin logged in). Check TODO plz.
My Testing procedure:
The problem is related to the code below:
final ParseObject object = ParseObject('Subscribers');
final response = await object.create();
if (response.success && response.count > 0) {
final ParseObject record = response.results[0];
record.set('name', name);
record.set('adminId', adminId);
await record.save();
}
Note that first you create the object with no adminId
and that's why your event is not triggered. You then set the adminId
and update the object. In that moment, your enter event should be triggered. Please listen to all different events (create, enter, update, leave, delete) and you will see it happening.