Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 400090b

Browse files
captbaritonefacebook-github-bot
authored andcommitted
Make LiveState and suspenseSentinel top level exports of Relay
Reviewed By: voideanvalue Differential Revision: D51287170 fbshipit-source-id: a08b0091b68c084f89da281630b854867a09aebf
1 parent 59f5d60 commit 400090b

31 files changed

+67
-68
lines changed

packages/relay-runtime/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ const {
3434
} = require('./store/ClientID');
3535
const createFragmentSpecResolver = require('./store/createFragmentSpecResolver');
3636
const createRelayContext = require('./store/createRelayContext');
37+
const {
38+
suspenseSentinel,
39+
} = require('./store/experimental-live-resolvers/LiveResolverSuspenseSentinel');
3740
const isRelayModernEnvironment = require('./store/isRelayModernEnvironment');
3841
const normalizeResponse = require('./store/normalizeResponse');
3942
const readInlineData = require('./store/readInlineData');
@@ -162,6 +165,7 @@ export type {
162165
StoreUpdater,
163166
UpdatableData,
164167
TaskScheduler,
168+
LiveState,
165169
} from './store/RelayStoreTypes';
166170
export type {
167171
GraphQLSubscriptionConfig,
@@ -300,6 +304,7 @@ module.exports = {
300304
graphql: GraphQLTag.graphql,
301305
isFragment: GraphQLTag.isFragment,
302306
isInlineDataFragment: GraphQLTag.isInlineDataFragment,
307+
suspenseSentinel,
303308
isRequest: GraphQLTag.isRequest,
304309
readInlineData,
305310

packages/relay-runtime/store/RelayStoreTypes.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,3 +1290,25 @@ export interface PublishQueue {
12901290
export type ConcreteClientEdgeResolverReturnType<T = any> = {
12911291
+id: T & DataID,
12921292
};
1293+
1294+
/**
1295+
* The return type of a Live Resolver. Models an external value which can
1296+
* be read lazily and which might change over time. The subscribe method
1297+
* returns a callback which should be called when the value _may_ have changed.
1298+
*
1299+
* While over-notification (subscription notifications when the read value has
1300+
* not actually changed) is suported, for performance reasons, it is recommended
1301+
* that the provider of the LiveState value confirms that the value has indeed
1302+
* change before notifying Relay of the change.
1303+
*/
1304+
export type LiveState<+T> = {
1305+
/**
1306+
* Returns the current value of the live state.
1307+
*/
1308+
read(): T,
1309+
/**
1310+
* Subscribes to changes in the live state. The state provider should
1311+
* call the callback when the value of the live state changes.
1312+
*/
1313+
subscribe(cb: () => void): () => void,
1314+
};

packages/relay-runtime/store/__tests__/resolvers/CounterSuspendsWhenOdd.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@
1212
'use strict';
1313

1414
import type {CounterSuspendsWhenOdd$key} from './__generated__/CounterSuspendsWhenOdd.graphql';
15-
import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore';
15+
import type {LiveState} from 'relay-runtime';
1616

1717
const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore');
18-
const {graphql} = require('relay-runtime');
19-
const {
20-
suspenseSentinel,
21-
} = require('relay-runtime/store/experimental-live-resolvers/LiveResolverSuspenseSentinel');
18+
const {graphql, suspenseSentinel} = require('relay-runtime');
2219
const {readFragment} = require('relay-runtime/store/ResolverFragments');
2320

2421
/**

packages/relay-runtime/store/__tests__/resolvers/CounterSuspendsWhenOddOnUser.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111

1212
'use strict';
1313

14-
import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore';
14+
import type {LiveState} from 'relay-runtime';
1515

1616
const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore');
17-
const {
18-
suspenseSentinel,
19-
} = require('relay-runtime/store/experimental-live-resolvers/LiveResolverSuspenseSentinel');
17+
const {suspenseSentinel} = require('relay-runtime');
2018

2119
/**
2220
* @RelayResolver

packages/relay-runtime/store/__tests__/resolvers/InnerResolver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
'use strict';
1313

1414
import type {InnerResolver$key} from './__generated__/InnerResolver.graphql';
15-
import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore';
15+
import type {LiveState} from 'relay-runtime';
1616

1717
const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore');
1818
const {graphql} = require('relay-runtime');

packages/relay-runtime/store/__tests__/resolvers/LiveConstantClientEdgeResolver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
'use strict';
1313

1414
import type {ConcreteClientEdgeResolverReturnType} from 'relay-runtime';
15-
import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore';
15+
import type {LiveState} from 'relay-runtime';
1616

1717
/**
1818
* @RelayResolver

packages/relay-runtime/store/__tests__/resolvers/LiveCounterNoFragment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
'use strict';
1313

14-
import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore';
14+
import type {LiveState} from 'relay-runtime';
1515

1616
const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore');
1717

packages/relay-runtime/store/__tests__/resolvers/LiveCounterNoFragmentWithArg.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
'use strict';
1313

14-
import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore';
14+
import type {LiveState} from 'relay-runtime';
1515

1616
const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore');
1717

packages/relay-runtime/store/__tests__/resolvers/LiveCounterResolver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
'use strict';
1313

1414
import type {LiveCounterResolver$key} from './__generated__/LiveCounterResolver.graphql';
15-
import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore';
15+
import type {LiveState} from 'relay-runtime';
1616

1717
const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore');
1818
const {graphql} = require('relay-runtime');

packages/relay-runtime/store/__tests__/resolvers/LiveCounterWithPossibleMissingFragmentDataResolver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
'use strict';
1313

1414
import type {LiveCounterWithPossibleMissingFragmentDataResolverFragment$key} from './__generated__/LiveCounterWithPossibleMissingFragmentDataResolverFragment.graphql';
15-
import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore';
15+
import type {LiveState} from 'relay-runtime';
1616

1717
const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore');
1818
const {graphql} = require('relay-runtime');

0 commit comments

Comments
 (0)