Skip to content

liveQuery dosn't work. #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zenz opened this issue May 28, 2019 · 11 comments
Closed

liveQuery dosn't work. #177

zenz opened this issue May 28, 2019 · 11 comments

Comments

@zenz
Copy link
Contributor

zenz commented May 28, 2019

It dosn't work.
While I use :
LiveQuery liveQuery = LiveQuery();
await liveQuery.subscribe(query);

It will bring me this error:
NoSuchMethodError (NoSuchMethodError: The method 'contains' was called on null.

in the parse_live_query.dart file, it seems the object was not exist.

Originally posted by @zenz in #165 (comment)

@RodrigoSMarques
Copy link
Contributor

RodrigoSMarques commented May 28, 2019

@zenz
See this example.

    QueryBuilder<ParseObject> query =
        QueryBuilder<ParseObject>(ParseObject('TestAPI'))
          ..whereEqualTo('intNumber', 1);
    await liveQuery.subscribe(query);

Livequery needs to receive a QueryBuilder which is the query you want to monitor

@phillwiggins
Copy link
Member

@zenz
It looks as though you haven't provided your liveQueryURL upon instantiation.

Parse().initialize( ApplicationConstants.keyApplicationId, ApplicationConstants.keyParseServerUrl, liveQueryUrl: ApplicationConstants.keyLiveQueryUrl);

This should fix your issue.

@zenz
Copy link
Contributor Author

zenz commented May 28, 2019

@phillwiggins Thanks but it dosn't work.

here's my code.

Parse().initialize(keyParseApplicationId, keyParseServerUrl,
        liveQueryUrl: keyLiveQueryUrl, debug: true);

      QueryBuilder<ParseObject> query =
          QueryBuilder<ParseObject>(ParseObject('Diet_Plans'));
      LiveQuery liveQuery = LiveQuery();

      await liveQuery.subscribe(query);

      liveQuery.on(LiveQueryEvent.update, (value) {
        print('*** UPDATE ***: ${DateTime.now().toString()}\n $value ');
        print((value as ParseObject).objectId);
        print((value as ParseObject).updatedAt);
        print((value as ParseObject).createdAt);
        print((value as ParseObject).get('objectId'));
        print((value as ParseObject).get('updatedAt'));
        print((value as ParseObject).get('createdAt'));
      });

and keyLiveQueryUrl = "wss://myhost:myport/mypath"
and I can confirm LiveQuery Server working properly.

Parse Server :3.4.0

@phillwiggins
Copy link
Member

phillwiggins commented May 28, 2019 via email

@RodrigoSMarques
Copy link
Contributor

What is not working? Is the error message displayed?
Did you check if the Diet_Plans class is configured on the server for LiveQuery?
https://docs.parseplatform.org/parse-server/guide/#live-queries

@zenz
Copy link
Contributor Author

zenz commented May 28, 2019

dev_dependencies:
parse_server_sdk: ^1.0.21

It seems that Parse().initialize not working well with liveQueryUrl parameter.

So LiveQuery liveQuery = LiveQuery(); makes _client.data.liveQueryURL equals to null.
While I hard coding _client.data.liveQueryURL to correct url, then I met the _session is null issue.

@zenz
Copy link
Contributor Author

zenz commented May 28, 2019

@RodrigoSMarques first thing first. It's not an issue about LiveQuery Server configuration. it's an issue about Parse.Init process.

@RodrigoSMarques
Copy link
Contributor

RodrigoSMarques commented May 28, 2019

My code works for me.

Internally it switches from https to wss or http to ws

  Parse().initialize("xxxxxxxxDmPTmRjfoSwpTPPmGsPUMKYxxxxx",
      "https://api.XXXXXXXXXXXXX.com/1",
      clientKey: "XXXi3GejX3SIxpDgSbKHHV8uHUUP3QGiPPTlxxxx",
      autoSendSessionId: true,
      debug: false,
      liveQueryUrl: "https://api.XXXXXXXXXXXXX.com/1");

@RodrigoSMarques
Copy link
Contributor

Enable debug mode e put the execution log.

@zenz
Copy link
Contributor Author

zenz commented May 28, 2019

Sorry, it's my fault!
I just test the liveQuery code by modify the examples and didn't notice that the new example move the real Parse().initialize to another page. so this two initialize conflict. and create this issue.
It can be close now.

@zenz zenz closed this as completed May 28, 2019
@zenz
Copy link
Contributor Author

zenz commented May 28, 2019

But as a suggestion, should we add a initialized state in Parse object so that we cannot re-initialize it again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants