Skip to content

useParseQuery subscription #68

Open
@hugobarragon

Description

@hugobarragon

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions