Skip to content

[Help Wanted]: Can I add subscribers after ready() #2587

@MajStc

Description

@MajStc

Required Reading

  • Confirmed

Plugin Version

5.1.1

Mobile operating-system(s)

  • iOS
  • Android

Device Manufacturer(s) and Model(s)

Samsung Galaxy S21 5G

Device operating-systems(s)

Android 15

React Native / Expo version

Expo 53

What do you require assistance about?

I know example app defines all subscribers before firing ready(), but docs mention

The SDK buffers events until ready resolves, so listeners registered afterward may miss them.

Does that mean it's still safe to add subscribers later on, but may result in some data loss, or is it strictly anti-pattern for library?

Use Case:
User opens the app, we don't want to start location listener until they log in, but we do ready() in app.tsx empty dep array useEffect to be 100% sure we only call it once in app lifecycle.

Missing initial events are ok for us, we only care if it's reliable and will not affect any functionality.
I found some issues that we may encounter warns if events are dispatched without listener, but this is OK for us, as longs as it's not breaking anything.

[Optional] Plugin Code and/or Config

[Optional] Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions