GithubHelp home page GithubHelp logo

Comments (3)

radeno avatar radeno commented on August 16, 2024 1

You are right about subscribing and unaubscribing. But what about If i want to have one global subscriber and firing location request when i need to ?

Subscribing and unsubscribing and again and again for example 10 screens looks very complicated solution.

But have one app/root subscriber connected to Redux and just updating when is need looks more easier.

For example:

  • for some screens i need position no older than 10 seconds. Fire request
  • for some screens is 1 minúte enought. Do not fire request
  • same for accuracy
  • speed, dIstance and any other measure

If i need to making new listener for every screen on and off. It ist little bit “scratching with left hand on right ear”. Even when i need just one manual request to update my location

from react-native-location.

radeno avatar radeno commented on August 16, 2024 1

Maybe any other use cases.

Request location only once on rendering screen. But have one global listener as saved whole object to Redux or React Context. And based on it, when location is requested, tadaaa, rerender with fresh data.

If people are in move, by walk, bike, in car, in train ,in bus, in any other vehicle. And your list of points if sorted by distance, you want to render it only once. Instead you get very nice flickering effect because rerendering :)

Handling this use cases with every new listener or comparing data in "should render" method is not clean and its bloat code a bit.

from react-native-location.

matt-oakes avatar matt-oakes commented on August 16, 2024

👋 Thanks for the request!

You should already be able to do this by adding a listener and unsubscribing when you no longer want updates.

The methods mentioned are internal implementation details and should not be used.

from react-native-location.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.