Skip to content
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

useParseQuery subscription #68

Open
hugobarragon opened this issue Dec 21, 2021 · 3 comments
Open

useParseQuery subscription #68

hugobarragon opened this issue Dec 21, 2021 · 3 comments

Comments

@hugobarragon
Copy link

I'd like to request a feature / bug useParseQuery works good in mount/unmout scnearios, but with react-navigation they dont have this lifecycles so it is impossible to use useParseQuery because it will keep requesting / updating other Screens, and I think with this will bring other level of customization, ex: click on somthing and being able to stop requesting live.

It could actually be a solution to use the enableLiveQuery to start/stop at any time
Is it possible to change enableLiveQuery on options and will it start / stop

The main objective is something like this

import { useIsFocused } from '@react-navigation/native';
import React,{ useEffect} from 'react';
// ...

function App() {
  const isFocused = useIsFocused();
  const {results,liveQuerySubscription} = useParseQuery(query);

useEffect(()=>{
if(!isFocused ){
// stop requesting
 liveQuerySubscription.unsubscribe();
}

},[isFocused ])

  return <Text>{isFocused ? 'focused' : 'unfocused'}</Text>;
}

But exporting the liveQuerySubscription maybe would not be the greatest solution because when we return to the same srceen we, mount event will not be trigered and we want to start requesting again...

What you guys think would be the best solution?

@hugobarragon
Copy link
Author

should this work to stop / start live requesting on demand?

  const isFocused = useIsFocused();
  const {results} = useParseQuery(query,{enableLiveQuery  :isFocused });

@claudiarsl
Copy link

When I navigate between two screens it gives me this error on the console. I'm using useParseQuery in both but for different requests.

Image.from.iOS.MOV

@mtrezza mtrezza changed the title Feature request / bug: useParseQuery subscription useParseQuery subscription Dec 24, 2021
@JHuenerberg
Copy link

@claudiarsl Unfortunately, I have exactly the same problem. Were you able to solve the error somehow?

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