diff --git a/packages/relay-runtime/index.js b/packages/relay-runtime/index.js index 375a3c0260f15..6dd973ed2966a 100644 --- a/packages/relay-runtime/index.js +++ b/packages/relay-runtime/index.js @@ -34,6 +34,9 @@ const { } = require('./store/ClientID'); const createFragmentSpecResolver = require('./store/createFragmentSpecResolver'); const createRelayContext = require('./store/createRelayContext'); +const { + suspenseSentinel, +} = require('./store/experimental-live-resolvers/LiveResolverSuspenseSentinel'); const isRelayModernEnvironment = require('./store/isRelayModernEnvironment'); const normalizeResponse = require('./store/normalizeResponse'); const readInlineData = require('./store/readInlineData'); @@ -162,6 +165,7 @@ export type { StoreUpdater, UpdatableData, TaskScheduler, + LiveState, } from './store/RelayStoreTypes'; export type { GraphQLSubscriptionConfig, @@ -300,6 +304,7 @@ module.exports = { graphql: GraphQLTag.graphql, isFragment: GraphQLTag.isFragment, isInlineDataFragment: GraphQLTag.isInlineDataFragment, + suspenseSentinel, isRequest: GraphQLTag.isRequest, readInlineData, diff --git a/packages/relay-runtime/store/RelayStoreTypes.js b/packages/relay-runtime/store/RelayStoreTypes.js index dba8044aa0445..967fbaa443ef6 100644 --- a/packages/relay-runtime/store/RelayStoreTypes.js +++ b/packages/relay-runtime/store/RelayStoreTypes.js @@ -1290,3 +1290,25 @@ export interface PublishQueue { export type ConcreteClientEdgeResolverReturnType = { +id: T & DataID, }; + +/** + * The return type of a Live Resolver. Models an external value which can + * be read lazily and which might change over time. The subscribe method + * returns a callback which should be called when the value _may_ have changed. + * + * While over-notification (subscription notifications when the read value has + * not actually changed) is suported, for performance reasons, it is recommended + * that the provider of the LiveState value confirms that the value has indeed + * change before notifying Relay of the change. + */ +export type LiveState<+T> = { + /** + * Returns the current value of the live state. + */ + read(): T, + /** + * Subscribes to changes in the live state. The state provider should + * call the callback when the value of the live state changes. + */ + subscribe(cb: () => void): () => void, +}; diff --git a/packages/relay-runtime/store/__tests__/resolvers/CounterSuspendsWhenOdd.js b/packages/relay-runtime/store/__tests__/resolvers/CounterSuspendsWhenOdd.js index 9e13e641476ce..b8a3a188867cb 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/CounterSuspendsWhenOdd.js +++ b/packages/relay-runtime/store/__tests__/resolvers/CounterSuspendsWhenOdd.js @@ -12,13 +12,10 @@ 'use strict'; import type {CounterSuspendsWhenOdd$key} from './__generated__/CounterSuspendsWhenOdd.graphql'; -import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore'); -const {graphql} = require('relay-runtime'); -const { - suspenseSentinel, -} = require('relay-runtime/store/experimental-live-resolvers/LiveResolverSuspenseSentinel'); +const {graphql, suspenseSentinel} = require('relay-runtime'); const {readFragment} = require('relay-runtime/store/ResolverFragments'); /** diff --git a/packages/relay-runtime/store/__tests__/resolvers/CounterSuspendsWhenOddOnUser.js b/packages/relay-runtime/store/__tests__/resolvers/CounterSuspendsWhenOddOnUser.js index 0c548708ba4a9..b66e571659057 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/CounterSuspendsWhenOddOnUser.js +++ b/packages/relay-runtime/store/__tests__/resolvers/CounterSuspendsWhenOddOnUser.js @@ -11,12 +11,10 @@ 'use strict'; -import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore'); -const { - suspenseSentinel, -} = require('relay-runtime/store/experimental-live-resolvers/LiveResolverSuspenseSentinel'); +const {suspenseSentinel} = require('relay-runtime'); /** * @RelayResolver diff --git a/packages/relay-runtime/store/__tests__/resolvers/InnerResolver.js b/packages/relay-runtime/store/__tests__/resolvers/InnerResolver.js index 8ef1472181427..99a7441f1b4e8 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/InnerResolver.js +++ b/packages/relay-runtime/store/__tests__/resolvers/InnerResolver.js @@ -12,7 +12,7 @@ 'use strict'; import type {InnerResolver$key} from './__generated__/InnerResolver.graphql'; -import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore'); const {graphql} = require('relay-runtime'); diff --git a/packages/relay-runtime/store/__tests__/resolvers/LiveConstantClientEdgeResolver.js b/packages/relay-runtime/store/__tests__/resolvers/LiveConstantClientEdgeResolver.js index 0fd6b24ab020c..8e3fb77253a1c 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/LiveConstantClientEdgeResolver.js +++ b/packages/relay-runtime/store/__tests__/resolvers/LiveConstantClientEdgeResolver.js @@ -12,7 +12,7 @@ 'use strict'; import type {ConcreteClientEdgeResolverReturnType} from 'relay-runtime'; -import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; /** * @RelayResolver diff --git a/packages/relay-runtime/store/__tests__/resolvers/LiveCounterNoFragment.js b/packages/relay-runtime/store/__tests__/resolvers/LiveCounterNoFragment.js index f38239b17a615..85add36f283ec 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/LiveCounterNoFragment.js +++ b/packages/relay-runtime/store/__tests__/resolvers/LiveCounterNoFragment.js @@ -11,7 +11,7 @@ 'use strict'; -import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore'); diff --git a/packages/relay-runtime/store/__tests__/resolvers/LiveCounterNoFragmentWithArg.js b/packages/relay-runtime/store/__tests__/resolvers/LiveCounterNoFragmentWithArg.js index 05a0675d9e8e9..3f95ed68cbd53 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/LiveCounterNoFragmentWithArg.js +++ b/packages/relay-runtime/store/__tests__/resolvers/LiveCounterNoFragmentWithArg.js @@ -11,7 +11,7 @@ 'use strict'; -import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore'); diff --git a/packages/relay-runtime/store/__tests__/resolvers/LiveCounterResolver.js b/packages/relay-runtime/store/__tests__/resolvers/LiveCounterResolver.js index a53216c86ebff..ce609ded42ee1 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/LiveCounterResolver.js +++ b/packages/relay-runtime/store/__tests__/resolvers/LiveCounterResolver.js @@ -12,7 +12,7 @@ 'use strict'; import type {LiveCounterResolver$key} from './__generated__/LiveCounterResolver.graphql'; -import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore'); const {graphql} = require('relay-runtime'); diff --git a/packages/relay-runtime/store/__tests__/resolvers/LiveCounterWithPossibleMissingFragmentDataResolver.js b/packages/relay-runtime/store/__tests__/resolvers/LiveCounterWithPossibleMissingFragmentDataResolver.js index 042650fe04351..10a205868d4ea 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/LiveCounterWithPossibleMissingFragmentDataResolver.js +++ b/packages/relay-runtime/store/__tests__/resolvers/LiveCounterWithPossibleMissingFragmentDataResolver.js @@ -12,7 +12,7 @@ 'use strict'; import type {LiveCounterWithPossibleMissingFragmentDataResolverFragment$key} from './__generated__/LiveCounterWithPossibleMissingFragmentDataResolverFragment.graphql'; -import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore'); const {graphql} = require('relay-runtime'); diff --git a/packages/relay-runtime/store/__tests__/resolvers/LiveExternalGreeting.js b/packages/relay-runtime/store/__tests__/resolvers/LiveExternalGreeting.js index 658e47041d994..19c91d4e540e9 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/LiveExternalGreeting.js +++ b/packages/relay-runtime/store/__tests__/resolvers/LiveExternalGreeting.js @@ -12,12 +12,9 @@ 'use strict'; import type {LiveExternalGreetingFragment$key} from './__generated__/LiveExternalGreetingFragment.graphql'; -import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; -const {graphql} = require('relay-runtime'); -const { - suspenseSentinel, -} = require('relay-runtime/store/experimental-live-resolvers/LiveResolverSuspenseSentinel'); +const {graphql, suspenseSentinel} = require('relay-runtime'); const {readFragment} = require('relay-runtime/store/ResolverFragments'); /** diff --git a/packages/relay-runtime/store/__tests__/resolvers/LivePingPongResolver.js b/packages/relay-runtime/store/__tests__/resolvers/LivePingPongResolver.js index c4e1f24b1937f..2ebac93526b16 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/LivePingPongResolver.js +++ b/packages/relay-runtime/store/__tests__/resolvers/LivePingPongResolver.js @@ -12,7 +12,7 @@ 'use strict'; import type {LivePingPongResolver$key} from './__generated__/LivePingPongResolver.graphql'; -import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; const {graphql} = require('relay-runtime'); const {readFragment} = require('relay-runtime/store/ResolverFragments'); diff --git a/packages/relay-runtime/store/__tests__/resolvers/LiveResolvers-test.js b/packages/relay-runtime/store/__tests__/resolvers/LiveResolvers-test.js index 35ba891ed9f18..b0198a50b6533 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/LiveResolvers-test.js +++ b/packages/relay-runtime/store/__tests__/resolvers/LiveResolvers-test.js @@ -15,7 +15,7 @@ import type {Snapshot} from '../../RelayStoreTypes'; const { live_external_greeting: LiveExternalGreeting, } = require('./LiveExternalGreeting'); -const {RelayFeatureFlags} = require('relay-runtime'); +const {RelayFeatureFlags, suspenseSentinel} = require('relay-runtime'); const RelayNetwork = require('relay-runtime/network/RelayNetwork'); const {graphql} = require('relay-runtime/query/GraphQLTag'); const { @@ -23,9 +23,6 @@ const { resetStore, } = require('relay-runtime/store/__tests__/resolvers/ExampleExternalStateStore'); const LiveResolverStore = require('relay-runtime/store/experimental-live-resolvers/LiveResolverStore'); -const { - suspenseSentinel, -} = require('relay-runtime/store/experimental-live-resolvers/LiveResolverSuspenseSentinel'); const RelayModernEnvironment = require('relay-runtime/store/RelayModernEnvironment'); const { createOperationDescriptor, diff --git a/packages/relay-runtime/store/__tests__/resolvers/LiveUserAlwaysSuspendResolver.js b/packages/relay-runtime/store/__tests__/resolvers/LiveUserAlwaysSuspendResolver.js index 799fc96093340..dfa547939d5d4 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/LiveUserAlwaysSuspendResolver.js +++ b/packages/relay-runtime/store/__tests__/resolvers/LiveUserAlwaysSuspendResolver.js @@ -12,11 +12,9 @@ 'use strict'; import type {ConcreteClientEdgeResolverReturnType} from 'relay-runtime'; -import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; -const { - suspenseSentinel, -} = require('relay-runtime/store/experimental-live-resolvers/LiveResolverSuspenseSentinel'); +const {suspenseSentinel} = require('relay-runtime'); /** * @RelayResolver diff --git a/packages/relay-runtime/store/__tests__/resolvers/LiveUserSuspendsWhenOdd.js b/packages/relay-runtime/store/__tests__/resolvers/LiveUserSuspendsWhenOdd.js index b4e941243d053..77b526512efe2 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/LiveUserSuspendsWhenOdd.js +++ b/packages/relay-runtime/store/__tests__/resolvers/LiveUserSuspendsWhenOdd.js @@ -12,12 +12,10 @@ 'use strict'; import type {DataID} from 'relay-runtime'; -import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore'); -const { - suspenseSentinel, -} = require('relay-runtime/store/experimental-live-resolvers/LiveResolverSuspenseSentinel'); +const {suspenseSentinel} = require('relay-runtime'); /** * @RelayResolver diff --git a/packages/relay-runtime/store/__tests__/resolvers/MutableModel.js b/packages/relay-runtime/store/__tests__/resolvers/MutableModel.js index 0b8f74868ae4e..8ad9107eccd8a 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/MutableModel.js +++ b/packages/relay-runtime/store/__tests__/resolvers/MutableModel.js @@ -11,7 +11,7 @@ 'use strict'; -import type {LiveState} from '../../experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; type Entity = { name: string, diff --git a/packages/relay-runtime/store/__tests__/resolvers/QueryLiveResolverReturnsUndefined.js b/packages/relay-runtime/store/__tests__/resolvers/QueryLiveResolverReturnsUndefined.js index 5531c50a0d3b4..373d6e6cf47a8 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/QueryLiveResolverReturnsUndefined.js +++ b/packages/relay-runtime/store/__tests__/resolvers/QueryLiveResolverReturnsUndefined.js @@ -11,6 +11,8 @@ 'use strict'; +import type {LiveState} from 'relay-runtime'; + /** * @RelayResolver * @fieldName live_resolver_return_undefined @@ -19,8 +21,6 @@ * * A @live resolver that throws */ -import type {LiveState} from '../../experimental-live-resolvers/LiveResolverStore'; - // $FlowFixMe - this resolver returns undefined, but should return LiveState function live_resolver_return_undefined(): LiveState<$FlowFixMe> {} diff --git a/packages/relay-runtime/store/__tests__/resolvers/QueryLiveResolverThrows.js b/packages/relay-runtime/store/__tests__/resolvers/QueryLiveResolverThrows.js index fda5822eb9f30..f4f3f3a370795 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/QueryLiveResolverThrows.js +++ b/packages/relay-runtime/store/__tests__/resolvers/QueryLiveResolverThrows.js @@ -11,6 +11,8 @@ 'use strict'; +import type {LiveState} from 'relay-runtime'; + /** * @RelayResolver * @fieldName live_resolver_throws @@ -19,8 +21,6 @@ * * A @live resolver that throws */ -import type {LiveState} from '../../experimental-live-resolvers/LiveResolverStore'; - function live_resolver_throws(): LiveState { throw new Error('What?'); } diff --git a/packages/relay-runtime/store/__tests__/resolvers/QueryLiveResolverThrowsOnRead.js b/packages/relay-runtime/store/__tests__/resolvers/QueryLiveResolverThrowsOnRead.js index 6f971c4bc82a9..84a0d850116b1 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/QueryLiveResolverThrowsOnRead.js +++ b/packages/relay-runtime/store/__tests__/resolvers/QueryLiveResolverThrowsOnRead.js @@ -11,7 +11,7 @@ 'use strict'; -import type {LiveState} from '../../experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore'); diff --git a/packages/relay-runtime/store/__tests__/resolvers/QueryLiveResolverWithBadReturnValue.js b/packages/relay-runtime/store/__tests__/resolvers/QueryLiveResolverWithBadReturnValue.js index aed51e23abbfd..0fe4c8e2984cb 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/QueryLiveResolverWithBadReturnValue.js +++ b/packages/relay-runtime/store/__tests__/resolvers/QueryLiveResolverWithBadReturnValue.js @@ -10,6 +10,7 @@ */ 'use strict'; +import type {LiveState} from 'relay-runtime'; /** * @RelayResolver @@ -19,8 +20,6 @@ * * A @live resolver that does not return a LiveObject */ -import type {LiveState} from '../../experimental-live-resolvers/LiveResolverStore'; - function live_resolver_with_bad_return_value(): LiveState { // $FlowFixMe The purpose of this resolver is to test a bad return value. return 'Oops!'; diff --git a/packages/relay-runtime/store/__tests__/resolvers/QueryManyLiveTodos.js b/packages/relay-runtime/store/__tests__/resolvers/QueryManyLiveTodos.js index 4c4f1c4bfd037..befada40127ca 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/QueryManyLiveTodos.js +++ b/packages/relay-runtime/store/__tests__/resolvers/QueryManyLiveTodos.js @@ -10,8 +10,7 @@ */ 'use strict'; - -import type {LiveState} from '../../experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; const { Selectors, diff --git a/packages/relay-runtime/store/__tests__/resolvers/QueryNonLiveResolverWithLiveReturnValue.js b/packages/relay-runtime/store/__tests__/resolvers/QueryNonLiveResolverWithLiveReturnValue.js index 587f72149c066..0c40a410e1516 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/QueryNonLiveResolverWithLiveReturnValue.js +++ b/packages/relay-runtime/store/__tests__/resolvers/QueryNonLiveResolverWithLiveReturnValue.js @@ -10,6 +10,7 @@ */ 'use strict'; +import type {LiveState} from 'relay-runtime'; /** * @RelayResolver @@ -18,8 +19,6 @@ * * A non-@live resolver that returns a LiveObject */ -import type {LiveState} from '../../experimental-live-resolvers/LiveResolverStore'; - function non_live_resolver_with_live_return_value(): LiveState { return { read() { diff --git a/packages/relay-runtime/store/__tests__/resolvers/QueryTodo.js b/packages/relay-runtime/store/__tests__/resolvers/QueryTodo.js index a74f2aa6e5d12..d7fcaa5191ba7 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/QueryTodo.js +++ b/packages/relay-runtime/store/__tests__/resolvers/QueryTodo.js @@ -11,8 +11,8 @@ 'use strict'; -import type {LiveState} from '../../experimental-live-resolvers/LiveResolverStore'; import type {Query__todo$normalization as ReturnType} from './__generated__/Query__todo$normalization.graphql'; +import type {LiveState} from 'relay-runtime'; const { Selectors, diff --git a/packages/relay-runtime/store/__tests__/resolvers/QueryTodos.js b/packages/relay-runtime/store/__tests__/resolvers/QueryTodos.js index eeb41393141fb..c58baf0ed9fd2 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/QueryTodos.js +++ b/packages/relay-runtime/store/__tests__/resolvers/QueryTodos.js @@ -11,8 +11,8 @@ 'use strict'; -import type {LiveState} from '../../experimental-live-resolvers/LiveResolverStore'; import type {Query__todos$normalization as ReturnType} from './__generated__/Query__todos$normalization.graphql'; +import type {LiveState} from 'relay-runtime'; const { Selectors, diff --git a/packages/relay-runtime/store/__tests__/resolvers/QueryVirgoLiveSuspendsWhenOddResolver.js b/packages/relay-runtime/store/__tests__/resolvers/QueryVirgoLiveSuspendsWhenOddResolver.js index ad3dab134063e..3bac919583994 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/QueryVirgoLiveSuspendsWhenOddResolver.js +++ b/packages/relay-runtime/store/__tests__/resolvers/QueryVirgoLiveSuspendsWhenOddResolver.js @@ -12,12 +12,10 @@ 'use strict'; import type {AstrologicalSignID} from './AstrologicalSignUtils'; -import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore'); -const { - suspenseSentinel, -} = require('relay-runtime/store/experimental-live-resolvers/LiveResolverSuspenseSentinel'); +const {suspenseSentinel} = require('relay-runtime'); /** * @RelayResolver Query.virgo_suspends_when_counter_is_odd: AstrologicalSign diff --git a/packages/relay-runtime/store/__tests__/resolvers/ResolverThatThrows.js b/packages/relay-runtime/store/__tests__/resolvers/ResolverThatThrows.js index 30e9adb1453c0..82874b8980687 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/ResolverThatThrows.js +++ b/packages/relay-runtime/store/__tests__/resolvers/ResolverThatThrows.js @@ -12,7 +12,7 @@ 'use strict'; import type {ResolverThatThrows$key} from './__generated__/ResolverThatThrows.graphql'; -import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; const {graphql} = require('relay-runtime'); const {readFragment} = require('relay-runtime/store/ResolverFragments'); diff --git a/packages/relay-runtime/store/__tests__/resolvers/TodoModel.js b/packages/relay-runtime/store/__tests__/resolvers/TodoModel.js index 2d62a3bd40017..66955a068c54b 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/TodoModel.js +++ b/packages/relay-runtime/store/__tests__/resolvers/TodoModel.js @@ -15,19 +15,16 @@ import type {TodoModelCapitalizedID$key} from './__generated__/TodoModelCapitali import type {TodoModelCapitalizedIDLegacy$key} from './__generated__/TodoModelCapitalizedIDLegacy.graphql'; import type {TodoDescription} from './TodoDescription'; import type {ConcreteClientEdgeResolverReturnType} from 'relay-runtime'; +import type {LiveState} from 'relay-runtime'; import type {TodoItem} from 'relay-runtime/store/__tests__/resolvers/ExampleTodoStore'; -import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore'; const {readFragment} = require('../../ResolverFragments'); const {createTodoDescription} = require('./TodoDescription'); -const {graphql} = require('relay-runtime'); +const {graphql, suspenseSentinel} = require('relay-runtime'); const { Selectors, TODO_STORE, } = require('relay-runtime/store/__tests__/resolvers/ExampleTodoStore'); -const { - suspenseSentinel, -} = require('relay-runtime/store/experimental-live-resolvers/LiveResolverSuspenseSentinel'); type TodoModelType = ?TodoItem; diff --git a/packages/relay-runtime/store/__tests__/resolvers/TodoSelfResolver.js b/packages/relay-runtime/store/__tests__/resolvers/TodoSelfResolver.js index dc9509718b23d..774dd1b095bee 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/TodoSelfResolver.js +++ b/packages/relay-runtime/store/__tests__/resolvers/TodoSelfResolver.js @@ -11,8 +11,8 @@ 'use strict'; -import type {LiveState} from '../../experimental-live-resolvers/LiveResolverStore'; import type {TodoSelfResolverFragment$key} from './__generated__/TodoSelfResolverFragment.graphql'; +import type {LiveState} from 'relay-runtime'; import type {TodoItem} from 'relay-runtime/store/__tests__/resolvers/ExampleTodoStore'; const {graphql} = require('relay-runtime'); diff --git a/packages/relay-runtime/store/__tests__/resolvers/UserProfilePictureUriSuspendsWhenTheCounterIsOdd.js b/packages/relay-runtime/store/__tests__/resolvers/UserProfilePictureUriSuspendsWhenTheCounterIsOdd.js index d572d787b1993..a5b34424d496a 100644 --- a/packages/relay-runtime/store/__tests__/resolvers/UserProfilePictureUriSuspendsWhenTheCounterIsOdd.js +++ b/packages/relay-runtime/store/__tests__/resolvers/UserProfilePictureUriSuspendsWhenTheCounterIsOdd.js @@ -12,13 +12,10 @@ 'use strict'; import type {UserProfilePictureUriSuspendsWhenTheCounterIsOdd$key} from './__generated__/UserProfilePictureUriSuspendsWhenTheCounterIsOdd.graphql'; -import type {LiveState} from 'relay-runtime/store/experimental-live-resolvers/LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; const {GLOBAL_STORE, Selectors} = require('./ExampleExternalStateStore'); -const {graphql} = require('relay-runtime'); -const { - suspenseSentinel, -} = require('relay-runtime/store/experimental-live-resolvers/LiveResolverSuspenseSentinel'); +const {graphql, suspenseSentinel} = require('relay-runtime'); const {readFragment} = require('relay-runtime/store/ResolverFragments'); /** diff --git a/packages/relay-runtime/store/experimental-live-resolvers/LiveResolverCache.js b/packages/relay-runtime/store/experimental-live-resolvers/LiveResolverCache.js index 0831b7caadec3..cd669ea9f080c 100644 --- a/packages/relay-runtime/store/experimental-live-resolvers/LiveResolverCache.js +++ b/packages/relay-runtime/store/experimental-live-resolvers/LiveResolverCache.js @@ -32,7 +32,7 @@ import type { ResolverCache, } from '../ResolverCache'; import type LiveResolverStore from './LiveResolverStore'; -import type {LiveState} from './LiveResolverStore'; +import type {LiveState} from 'relay-runtime'; const recycleNodesInto = require('../../util/recycleNodesInto'); const {RELAY_LIVE_RESOLVER} = require('../../util/RelayConcreteNode'); diff --git a/packages/relay-runtime/store/experimental-live-resolvers/LiveResolverStore.js b/packages/relay-runtime/store/experimental-live-resolvers/LiveResolverStore.js index 4de21cb2f7a58..b87ff23356a49 100644 --- a/packages/relay-runtime/store/experimental-live-resolvers/LiveResolverStore.js +++ b/packages/relay-runtime/store/experimental-live-resolvers/LiveResolverStore.js @@ -55,10 +55,8 @@ const { } = require('./LiveResolverCache'); const invariant = require('invariant'); -export type LiveState<+T> = { - read(): T, - subscribe(cb: () => void): () => void, -}; +// Used by codegen. +export type {LiveState} from '../RelayStoreTypes'; // HACK // The type of Store is defined using an opaque type that only RelayModernStore