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

fix: RN streamer connection in background and foreground. #360

Merged

Conversation

yusinto
Copy link
Contributor

@yusinto yusinto commented Feb 1, 2024

This PR adds a new hook useAppState to manage streamer connections on AppState transitions. This version is slightly different to the iOS and Flutter logic. The transition handler is debounced here so excessive transitions don't result in equally excessive start stop of the EventSource.

… where single contexts with attributes called ld_application and ld_device are not added with auto env attributes.
Copy link

This pull request has been linked to Shortcut Story #228044: RN sdk should disable streaming in background.

appState.current = nextAppState;
};

// debounce with a default delay of 5 seconds.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will likely not run sometimes on iOS, or maybe at all, when transitioning to the background. But that is probably fine, because restoring entering the foreground will be more important. My only concern will be if we end up basically superseding the transition with the retry.

Theoretically, on iOS, you only are certain to be able to execute during the transition, and not after. Which is the reason flutter doesn't debounce it, even though I would generally like to.

Base automatically changed from yus/sc-225912/implement-rn-eventsource-jitter-backoff to main February 1, 2024 20:36
@yusinto yusinto merged commit c69b768 into main Feb 1, 2024
16 checks passed
@yusinto yusinto deleted the yus/sc-228044/rn-sdk-should-disable-streaming-in-background branch February 1, 2024 20:46
@github-actions github-actions bot mentioned this pull request Feb 1, 2024
yusinto pushed a commit that referenced this pull request Feb 6, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>akamai-edgeworker-sdk-common: 1.1.0</summary>

##
[1.1.0](akamai-edgeworker-sdk-common-v1.0.6...akamai-edgeworker-sdk-common-v1.1.0)
(2024-02-06)


### Features

* React-native support for auto-env attributes. Only affects
react-native package.
([deea99c](deea99c))
* Update eslint jest configuration and versions.
([deea99c](deea99c))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-server-sdk-common bumped from ^2.1.3 to ^2.2.0
</details>

<details><summary>akamai-server-base-sdk: 2.1.0</summary>

##
[2.1.0](akamai-server-base-sdk-v2.0.6...akamai-server-base-sdk-v2.1.0)
(2024-02-06)


### Features

* React-native support for auto-env attributes. Only affects
react-native package.
([deea99c](deea99c))
* Update eslint jest configuration and versions.
([deea99c](deea99c))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
* @launchdarkly/akamai-edgeworker-sdk-common bumped from ^1.0.6 to
^1.1.0
    * @launchdarkly/js-server-sdk-common bumped from ^2.1.3 to ^2.2.0
</details>

<details><summary>akamai-server-edgekv-sdk: 1.1.0</summary>

##
[1.1.0](akamai-server-edgekv-sdk-v1.0.14...akamai-server-edgekv-sdk-v1.1.0)
(2024-02-06)


### Features

* React-native support for auto-env attributes. Only affects
react-native package.
([deea99c](deea99c))
* Update eslint jest configuration and versions.
([deea99c](deea99c))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
* @launchdarkly/akamai-edgeworker-sdk-common bumped from ^1.0.6 to
^1.1.0
    * @launchdarkly/js-server-sdk-common bumped from ^2.1.3 to ^2.2.0
</details>

<details><summary>cloudflare-server-sdk: 2.4.0</summary>

##
[2.4.0](cloudflare-server-sdk-v2.3.3...cloudflare-server-sdk-v2.4.0)
(2024-02-06)


### Features

* React-native support for auto-env attributes. Only affects
react-native package.
([deea99c](deea99c))
* Update eslint jest configuration and versions.
([deea99c](deea99c))


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/js-server-sdk-common-edge bumped from 2.1.3 to 2.2.0
</details>

<details><summary>js-client-sdk-common: 0.2.0</summary>

##
[0.2.0](js-client-sdk-common-v0.1.2...js-client-sdk-common-v0.2.0)
(2024-02-06)


### Features

* Implement common client side support for auto environment attributes.
([#356](#356))
([8d80259](8d80259))
* React-native support for auto-env attributes. Only affects
react-native package.
([deea99c](deea99c))
* Update eslint jest configuration and versions.
([deea99c](deea99c))


### Bug Fixes

* Add LDOptions.application name and versionName.
([#358](#358))
([cd75210](cd75210))
* Add RN SDK offline support through ConnectionMode.
([#361](#361))
([d97ce82](d97ce82))
* Implement anonymous context processing
([#350](#350))
([308100d](308100d))
* Improvements and fixes from docs review.
([#362](#362))
([ba07fbf](ba07fbf))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-sdk-common bumped from 2.1.1 to 2.2.0
</details>

<details><summary>js-sdk-common: 2.2.0</summary>

##
[2.2.0](js-sdk-common-v2.1.1...js-sdk-common-v2.2.0)
(2024-02-06)


### Features

* Implement common client side support for auto environment attributes.
([#356](#356))
([8d80259](8d80259))
* Implement common support for auto environment attributes.
([#355](#355))
([9f562e5](9f562e5))
* React-native support for auto-env attributes. Only affects
react-native package.
([deea99c](deea99c))
* Update eslint jest configuration and versions.
([deea99c](deea99c))


### Bug Fixes

* Add LDOptions.application name and versionName.
([#358](#358))
([cd75210](cd75210))
* Add RN SDK offline support through ConnectionMode.
([#361](#361))
([d97ce82](d97ce82))
* Implement anonymous context processing
([#350](#350))
([308100d](308100d))
* RN streamer connection in background and foreground.
([#360](#360))
([c69b768](c69b768))
</details>

<details><summary>js-server-sdk-common: 2.2.0</summary>

##
[2.2.0](js-server-sdk-common-v2.1.3...js-server-sdk-common-v2.2.0)
(2024-02-06)


### Features

* Implement common client side support for auto environment attributes.
([#356](#356))
([8d80259](8d80259))
* React-native support for auto-env attributes. Only affects
react-native package.
([deea99c](deea99c))
* Update eslint jest configuration and versions.
([deea99c](deea99c))


### Bug Fixes

* Add LDOptions.application name and versionName.
([#358](#358))
([cd75210](cd75210))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-sdk-common bumped from 2.1.1 to 2.2.0
</details>

<details><summary>js-server-sdk-common-edge: 2.2.0</summary>

##
[2.2.0](js-server-sdk-common-edge-v2.1.3...js-server-sdk-common-edge-v2.2.0)
(2024-02-06)


### Features

* Implement common client side support for auto environment attributes.
([#356](#356))
([8d80259](8d80259))
* React-native support for auto-env attributes. Only affects
react-native package.
([deea99c](deea99c))
* Update eslint jest configuration and versions.
([deea99c](deea99c))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-server-sdk-common bumped from 2.1.3 to 2.2.0
</details>

<details><summary>node-server-sdk: 9.1.0</summary>

##
[9.1.0](node-server-sdk-v9.0.6...node-server-sdk-v9.1.0)
(2024-02-06)


### Features

* React-native support for auto-env attributes. Only affects
react-native package.
([deea99c](deea99c))
* Update eslint jest configuration and versions.
([deea99c](deea99c))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-server-sdk-common bumped from 2.1.3 to 2.2.0
</details>

<details><summary>node-server-sdk-dynamodb: 6.1.0</summary>

##
[6.1.0](node-server-sdk-dynamodb-v6.0.6...node-server-sdk-dynamodb-v6.1.0)
(2024-02-06)


### Features

* React-native support for auto-env attributes. Only affects
react-native package.
([deea99c](deea99c))
* Update eslint jest configuration and versions.
([deea99c](deea99c))


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/node-server-sdk bumped from 9.0.6 to 9.1.0
</details>

<details><summary>node-server-sdk-redis: 4.1.0</summary>

##
[4.1.0](node-server-sdk-redis-v4.0.6...node-server-sdk-redis-v4.1.0)
(2024-02-06)


### Features

* React-native support for auto-env attributes. Only affects
react-native package.
([deea99c](deea99c))
* Update eslint jest configuration and versions.
([deea99c](deea99c))


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/node-server-sdk bumped from 9.0.6 to 9.1.0
</details>

<details><summary>react-native-client-sdk: 0.2.0</summary>

##
[0.2.0](react-native-client-sdk-v0.1.5...react-native-client-sdk-v0.2.0)
(2024-02-06)


### Features

* React-native support for auto-env attributes. Only affects
react-native package.
([deea99c](deea99c))
* Update eslint jest configuration and versions.
([deea99c](deea99c))


### Bug Fixes

* Add RN SDK offline support through ConnectionMode.
([#361](#361))
([d97ce82](d97ce82))
* Implement RN SDK EventSource jitter backoff.
([#359](#359))
([95e58bd](95e58bd))
* Improvements and fixes from docs review.
([#362](#362))
([ba07fbf](ba07fbf))
* RN streamer connection in background and foreground.
([#360](#360))
([c69b768](c69b768))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk-common bumped from 0.1.2 to 0.2.0
</details>

<details><summary>vercel-server-sdk: 1.3.0</summary>

##
[1.3.0](vercel-server-sdk-v1.2.3...vercel-server-sdk-v1.3.0)
(2024-02-06)


### Features

* React-native support for auto-env attributes. Only affects
react-native package.
([deea99c](deea99c))
* Update eslint jest configuration and versions.
([deea99c](deea99c))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-server-sdk-common-edge bumped from 2.1.3 to 2.2.0
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

3 participants