Skip to content

Commit

Permalink
Merge pull request #26789 from JKobrynski/migrateOnyxSubscribeToTypeS…
Browse files Browse the repository at this point in the history
…cript

[No QA] [TS Migration] migrate onyxSubscribe to TypeScript
  • Loading branch information
AndrewGable authored Sep 7, 2023
2 parents cced02d + 0ce567a commit 5668cfe
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"react-native-linear-gradient": "^2.8.1",
"react-native-localize": "^2.2.6",
"react-native-modal": "^13.0.0",
"react-native-onyx": "1.0.70",
"react-native-onyx": "1.0.72",
"react-native-pager-view": "^6.2.0",
"react-native-pdf": "^6.7.1",
"react-native-performance": "^4.0.0",
Expand Down
12 changes: 0 additions & 12 deletions src/libs/onyxSubscribe.js

This file was deleted.

15 changes: 15 additions & 0 deletions src/libs/onyxSubscribe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Onyx, {ConnectOptions} from 'react-native-onyx';
import {OnyxKey} from '../ONYXKEYS';

/**
* Connect to onyx data. Same params as Onyx.connect(), but returns a function to unsubscribe.
*
* @param mapping Same as for Onyx.connect()
* @return Unsubscribe callback
*/
function onyxSubscribe<TKey extends OnyxKey>(mapping: ConnectOptions<TKey>) {
const connectionId = Onyx.connect(mapping);
return () => Onyx.disconnect(connectionId);
}

export default onyxSubscribe;

0 comments on commit 5668cfe

Please sign in to comment.