react-rx 1.0.0-beta.6 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/compiler.xml +1 -1
- package/.idea/inspectionProfiles/Project_Default.xml +1 -0
- package/.idea/markdown.xml +9 -0
- package/.idea/misc.xml +0 -6
- package/dist/cjs/WithObservable.js +3 -3
- package/dist/cjs/displayName.js +1 -1
- package/dist/cjs/reactiveComponent.js +6 -6
- package/dist/cjs/useAsObservable.js +10 -18
- package/dist/cjs/useObservable.js +26 -31
- package/dist/cjs/useObservableCallback.js +4 -4
- package/dist/cjs/useWithObservable.js +2 -2
- package/dist/cjs/utils.js +7 -7
- package/dist/cjs/withPropsStream.js +8 -4
- package/dist/es2015/useAsObservable.js +10 -18
- package/dist/es2015/useObservable.js +24 -31
- package/dist/esm/displayName.js +1 -1
- package/dist/esm/useAsObservable.js +10 -18
- package/dist/esm/useObservable.js +26 -31
- package/package.json +5 -3
- package/src/useAsObservable.ts +13 -18
- package/src/useObservable.ts +39 -34
- package/.idea/workspace.xml +0 -228
- package/jest.config.js +0 -5
- package/website/.babelrc +0 -21
- package/website/.prettierrc +0 -7
- package/website/README.mdx +0 -1
- package/website/package.json +0 -84
- package/website/src/@types/babel.d.ts +0 -4
- package/website/src/@types/mdx.d.ts +0 -11
- package/website/src/@types/react-css-burger.d.ts +0 -4
- package/website/src/App.tsx +0 -68
- package/website/src/components/Header.tsx +0 -118
- package/website/src/components/Link.tsx +0 -18
- package/website/src/components/LoadPage.tsx +0 -60
- package/website/src/components/Sidebar.tsx +0 -88
- package/website/src/components/logos/Github.tsx +0 -10
- package/website/src/components/logos/React.tsx +0 -27
- package/website/src/components/logos/ReactRxLogo.tsx +0 -39
- package/website/src/components/logos/RxJs.tsx +0 -69
- package/website/src/components/repl/Checkerboard.tsx +0 -25
- package/website/src/components/repl/CodeBlock.tsx +0 -147
- package/website/src/components/repl/CodeMirror.tsx +0 -37
- package/website/src/components/repl/CodeMirrorMode.tsx +0 -67
- package/website/src/components/repl/EvalCode.tsx +0 -55
- package/website/src/components/repl/Prelude.tsx +0 -50
- package/website/src/components/repl/ShowError.tsx +0 -27
- package/website/src/components/repl/codemirror-lib.ts +0 -8
- package/website/src/components/repl/codemirror-theme.css +0 -131
- package/website/src/components/repl/compile/babel.ts +0 -21
- package/website/src/components/repl/eval/evalCallback.ts +0 -27
- package/website/src/components/repl/eval/evalCode.ts +0 -7
- package/website/src/components/repl/eval/evalExpression.ts +0 -4
- package/website/src/components/repl/eval/evalReactDomRender.ts +0 -23
- package/website/src/components/repl/index.ts +0 -1
- package/website/src/components/repl/runMode.ts +0 -42
- package/website/src/datastores/location.ts +0 -14
- package/website/src/datastores/page.ts +0 -11
- package/website/src/datastores/pageTransition.ts +0 -97
- package/website/src/entries/main.css +0 -2
- package/website/src/entries/main.tsx +0 -6
- package/website/src/examples/FizzBuzz/FizzBuzzExample.tsx +0 -39
- package/website/src/examples/FizzBuzz/index.tsx +0 -9
- package/website/src/examples/_utils/globalScope.ts +0 -45
- package/website/src/examples/animation/AnimationExample.tsx +0 -152
- package/website/src/examples/animation/easings.ts +0 -0
- package/website/src/examples/animation/index.tsx +0 -15
- package/website/src/examples/context/Context.example.jsx +0 -67
- package/website/src/examples/context/index.tsx +0 -9
- package/website/src/examples/errors/Errors.example.jsx +0 -69
- package/website/src/examples/errors/index.tsx +0 -9
- package/website/src/examples/event-handlers/EventHandlersExample.tsx +0 -48
- package/website/src/examples/event-handlers/index.tsx +0 -9
- package/website/src/examples/fetch/FetchExample.jsx +0 -43
- package/website/src/examples/fetch/a.txt +0 -1
- package/website/src/examples/fetch/b.txt +0 -1
- package/website/src/examples/fetch/index.tsx +0 -9
- package/website/src/examples/form-data/FormDataExample.jsx +0 -119
- package/website/src/examples/form-data/index.tsx +0 -12
- package/website/src/examples/form-data/storage.ts +0 -27
- package/website/src/examples/forward-ref/ForwardRefExample.tsx +0 -55
- package/website/src/examples/forward-ref/index.tsx +0 -9
- package/website/src/examples/hello-world/HelloWorld.example.jsx +0 -6
- package/website/src/examples/hello-world/index.tsx +0 -9
- package/website/src/examples/hooks-interop/HooksInterop.example.tsx +0 -42
- package/website/src/examples/hooks-interop/index.tsx +0 -9
- package/website/src/examples/passthrough-props/PassThroughPropsExample.jsx +0 -57
- package/website/src/examples/passthrough-props/index.tsx +0 -11
- package/website/src/examples/reactive-state/ReactiveState.example.jsx +0 -43
- package/website/src/examples/reactive-state/index.ts +0 -9
- package/website/src/examples/readme-examples/README.mdx +0 -0
- package/website/src/examples/readme-examples/index.ts +0 -11
- package/website/src/examples/shared-state/SharedState.example.tsx +0 -59
- package/website/src/examples/shared-state/index.tsx +0 -9
- package/website/src/examples/simple/Counter.example.tsx +0 -14
- package/website/src/examples/simple/index.tsx +0 -9
- package/website/src/examples/sync/Sync.example.tsx +0 -9
- package/website/src/examples/sync/index.tsx +0 -9
- package/website/src/examples/tick/TickExample.jsx +0 -51
- package/website/src/examples/tick/index.ts +0 -9
- package/website/src/examples/todo-app/TodoApp.example.tsx +0 -88
- package/website/src/examples/todo-app/index.tsx +0 -12
- package/website/src/examples/todo-app/storage.ts +0 -27
- package/website/src/examples/use-element/UseElementExample.tsx +0 -70
- package/website/src/examples/use-element/index.tsx +0 -9
- package/website/src/examples/use-observable/search/SearchExample.tsx +0 -82
- package/website/src/examples/use-observable/search/index.tsx +0 -8
- package/website/src/examples/use-observable/use-observable/UseObservableExample.tsx +0 -70
- package/website/src/examples/use-observable/use-observable/index.tsx +0 -9
- package/website/src/index.html +0 -10
- package/website/src/mdx-components.tsx +0 -74
- package/website/src/pages/Api/Api.mdx +0 -134
- package/website/src/pages/Api/ApiPage.tsx +0 -25
- package/website/src/pages/Examples/Examples.tsx +0 -105
- package/website/src/pages/Examples/ExamplesPage.tsx +0 -13
- package/website/src/pages/Guide/Guide.mdx +0 -275
- package/website/src/pages/Guide/GuidePage.tsx +0 -25
- package/website/src/pages/Index/IndexPage.tsx +0 -50
- package/website/src/pages/Index/ReactRxReadme.md +0 -20
- package/website/src/pages/NotFound.tsx +0 -3
- package/website/src/pages/pages.ts +0 -46
- package/website/src/pages/styles.tsx +0 -24
- package/website/src/theme.ts +0 -61
- package/website/src/utils/parseCodeFenceHeader.ts +0 -32
- package/website/tsconfig.json +0 -30
- package/website/vercel.json +0 -4
- package/website/webpack/config.js +0 -5
- package/website/webpack/createConfig.js +0 -95
- package/website/webpack/mdx-toc-loader.js +0 -38
package/src/useObservable.ts
CHANGED
|
@@ -1,46 +1,51 @@
|
|
|
1
|
-
import {Observable,
|
|
2
|
-
import {DependencyList, useMemo
|
|
3
|
-
import {
|
|
1
|
+
import {defer, merge, Observable, of, pipe} from 'rxjs'
|
|
2
|
+
import {DependencyList, useMemo} from 'react'
|
|
3
|
+
import {useAsObservable} from './useAsObservable'
|
|
4
|
+
import {distinctUntilChanged, switchMap} from 'rxjs/operators'
|
|
5
|
+
import {useSyncExternalStore} from 'use-sync-external-store/shim'
|
|
4
6
|
|
|
5
7
|
function getValue<T>(value: T): T extends () => infer U ? U : T {
|
|
6
8
|
return typeof value === 'function' ? value() : value
|
|
7
9
|
}
|
|
8
10
|
|
|
11
|
+
function useObservableSubscription<T>(observable: Observable<T>): T {
|
|
12
|
+
const store = useMemo(() => {
|
|
13
|
+
let currentValue: T
|
|
14
|
+
return {
|
|
15
|
+
// Note: this works because the given observable always emits a value synchronously by concat-ing the given initialValue
|
|
16
|
+
getCurrentValue: () => currentValue,
|
|
17
|
+
subscribe: (callback: (value: T) => void) => {
|
|
18
|
+
const subscription = observable.subscribe(value => {
|
|
19
|
+
currentValue = value
|
|
20
|
+
callback(value)
|
|
21
|
+
})
|
|
22
|
+
return () => {
|
|
23
|
+
subscription.unsubscribe()
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
}, [observable])
|
|
28
|
+
return useSyncExternalStore(store.subscribe, store.getCurrentValue)
|
|
29
|
+
}
|
|
30
|
+
|
|
9
31
|
export function useObservable<T>(observable: Observable<T>): T | undefined
|
|
10
32
|
export function useObservable<T>(observable: Observable<T>, initialValue: T): T
|
|
11
33
|
export function useObservable<T>(observable: Observable<T>, initialValue: () => T): T
|
|
12
34
|
export function useObservable<T>(observable: Observable<T>, initialValue?: T | (() => T)) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
useIsomorphicEffect(() => {
|
|
30
|
-
// when the observable changes after initial (possibly sync render)
|
|
31
|
-
if (!isInitial.current) {
|
|
32
|
-
subscription.current = observable.subscribe(nextVal => setState(nextVal))
|
|
33
|
-
}
|
|
34
|
-
isInitial.current = false
|
|
35
|
-
return () => {
|
|
36
|
-
if (subscription.current) {
|
|
37
|
-
subscription.current.unsubscribe()
|
|
38
|
-
subscription.current = undefined
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}, [observable])
|
|
42
|
-
|
|
43
|
-
return value
|
|
35
|
+
return useObservableSubscription(
|
|
36
|
+
useAsObservable(
|
|
37
|
+
observable,
|
|
38
|
+
pipe(
|
|
39
|
+
distinctUntilChanged(),
|
|
40
|
+
switchMap(observable =>
|
|
41
|
+
merge(
|
|
42
|
+
defer(() => of(getValue(initialValue))),
|
|
43
|
+
observable,
|
|
44
|
+
),
|
|
45
|
+
),
|
|
46
|
+
),
|
|
47
|
+
),
|
|
48
|
+
)
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
export function useMemoObservable<T>(
|
package/.idea/workspace.xml
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ChangeListManager">
|
|
4
|
-
<list default="true" id="9f1530e5-3e67-4ff9-b8bc-a40f03478761" name="Default Changelist" comment="">
|
|
5
|
-
<change beforePath="$PROJECT_DIR$/../react-repl/src/Editor.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/../react-repl/src/Editor.tsx" afterDir="false" />
|
|
6
|
-
<change beforePath="$PROJECT_DIR$/../react-repl/src/ShowError.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/../react-repl/src/ShowError.tsx" afterDir="false" />
|
|
7
|
-
<change beforePath="$PROJECT_DIR$/../react-repl/src/transformers/babel.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../react-repl/src/transformers/babel.ts" afterDir="false" />
|
|
8
|
-
<change beforePath="$PROJECT_DIR$/../react-rx.dev/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/../react-rx.dev/package-lock.json" afterDir="false" />
|
|
9
|
-
<change beforePath="$PROJECT_DIR$/../react-rx.dev/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/../react-rx.dev/package.json" afterDir="false" />
|
|
10
|
-
<change beforePath="$PROJECT_DIR$/../react-rx.dev/src/pages/Index/ReactRxReadme.md" beforeDir="false" afterPath="$PROJECT_DIR$/../react-rx.dev/src/pages/Index/ReactRxReadme.md" afterDir="false" />
|
|
11
|
-
<change beforePath="$PROJECT_DIR$/src/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.ts" afterDir="false" />
|
|
12
|
-
<change beforePath="$PROJECT_DIR$/src/useObservable.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/useObservable.ts" afterDir="false" />
|
|
13
|
-
</list>
|
|
14
|
-
<option name="SHOW_DIALOG" value="false" />
|
|
15
|
-
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
16
|
-
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
17
|
-
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
18
|
-
</component>
|
|
19
|
-
<component name="ChangesViewManager">
|
|
20
|
-
<option name="groupingKeys">
|
|
21
|
-
<option value="directory" />
|
|
22
|
-
</option>
|
|
23
|
-
</component>
|
|
24
|
-
<component name="Git.Settings">
|
|
25
|
-
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
|
26
|
-
<option name="ROOT_SYNC" value="DONT_SYNC" />
|
|
27
|
-
</component>
|
|
28
|
-
<component name="GitSEFilterConfiguration">
|
|
29
|
-
<file-type-list>
|
|
30
|
-
<filtered-out-file-type name="LOCAL_BRANCH" />
|
|
31
|
-
<filtered-out-file-type name="REMOTE_BRANCH" />
|
|
32
|
-
<filtered-out-file-type name="TAG" />
|
|
33
|
-
<filtered-out-file-type name="COMMIT_BY_MESSAGE" />
|
|
34
|
-
</file-type-list>
|
|
35
|
-
</component>
|
|
36
|
-
<component name="MacroExpansionManager">
|
|
37
|
-
<option name="directoryName" value="iy052u10" />
|
|
38
|
-
</component>
|
|
39
|
-
<component name="ProjectId" id="1PI8FtTkoa1tFBP8398nQ82nYf0" />
|
|
40
|
-
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
|
41
|
-
<component name="ProjectViewState">
|
|
42
|
-
<option name="autoscrollToSource" value="true" />
|
|
43
|
-
<option name="hideEmptyMiddlePackages" value="true" />
|
|
44
|
-
<option name="showLibraryContents" value="true" />
|
|
45
|
-
</component>
|
|
46
|
-
<component name="PropertiesComponent">
|
|
47
|
-
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
|
48
|
-
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
|
49
|
-
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
|
|
50
|
-
<property name="com.intellij.ide.scratch.LRUPopupBuilder$1/New Scratch File" value="JavaScript" />
|
|
51
|
-
<property name="full.screen.before.presentation.mode" value="true" />
|
|
52
|
-
<property name="last.edited.regexp" value="jsx{1,2}" />
|
|
53
|
-
<property name="last_opened_file_path" value="$PROJECT_DIR$/src" />
|
|
54
|
-
<property name="node.js.detected.package.eslint" value="true" />
|
|
55
|
-
<property name="node.js.detected.package.standard" value="true" />
|
|
56
|
-
<property name="node.js.detected.package.tslint" value="true" />
|
|
57
|
-
<property name="node.js.path.for.package.eslint" value="project" />
|
|
58
|
-
<property name="node.js.path.for.package.standard" value="project" />
|
|
59
|
-
<property name="node.js.path.for.package.tslint" value="project" />
|
|
60
|
-
<property name="node.js.selected.package.eslint" value="(autodetect)" />
|
|
61
|
-
<property name="node.js.selected.package.standard" value="" />
|
|
62
|
-
<property name="node.js.selected.package.tslint" value="$PROJECT_DIR$/node_modules/tslint" />
|
|
63
|
-
<property name="nodejs.jest.jest_package" value="$PROJECT_DIR$/node_modules/jest" />
|
|
64
|
-
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
|
|
65
|
-
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
|
|
66
|
-
<property name="nodejs_package_manager_path" value="npm" />
|
|
67
|
-
<property name="prettierjs.PrettierConfiguration.Package" value="$PROJECT_DIR$/node_modules/prettier" />
|
|
68
|
-
<property name="settings.editor.selected.configurable" value="project.propVCSSupport.Mappings" />
|
|
69
|
-
<property name="ts.external.directory.path" value="$PROJECT_DIR$/node_modules/typescript/lib" />
|
|
70
|
-
<property name="vue.rearranger.settings.migration" value="true" />
|
|
71
|
-
</component>
|
|
72
|
-
<component name="RecentsManager">
|
|
73
|
-
<key name="CopyFile.RECENT_KEYS">
|
|
74
|
-
<recent name="$PROJECT_DIR$/src" />
|
|
75
|
-
<recent name="$PROJECT_DIR$/test-concurrent-mode" />
|
|
76
|
-
<recent name="$PROJECT_DIR$/website/src/examples" />
|
|
77
|
-
<recent name="$PROJECT_DIR$/src/__tests__" />
|
|
78
|
-
<recent name="$PROJECT_DIR$/../react-rx.dev" />
|
|
79
|
-
</key>
|
|
80
|
-
<key name="MoveFile.RECENT_KEYS">
|
|
81
|
-
<recent name="$PROJECT_DIR$/website/src/examples" />
|
|
82
|
-
<recent name="$PROJECT_DIR$/src" />
|
|
83
|
-
<recent name="$PROJECT_DIR$/../react-rx.dev/src" />
|
|
84
|
-
<recent name="$PROJECT_DIR$/../react-rx.dev/webpack" />
|
|
85
|
-
<recent name="$PROJECT_DIR$/../react-rx.dev/webpack-configs" />
|
|
86
|
-
</key>
|
|
87
|
-
</component>
|
|
88
|
-
<component name="RunManager" selected="Jest.useObservable.test.tsx">
|
|
89
|
-
<configuration name="All Tests" type="JavaScriptTestRunnerJest" nameIsGenerated="true">
|
|
90
|
-
<node-interpreter value="project" />
|
|
91
|
-
<node-options value="" />
|
|
92
|
-
<jest-package value="$PROJECT_DIR$/node_modules/jest" />
|
|
93
|
-
<working-dir value="$PROJECT_DIR$" />
|
|
94
|
-
<envs />
|
|
95
|
-
<scope-kind value="ALL" />
|
|
96
|
-
<method v="2" />
|
|
97
|
-
</configuration>
|
|
98
|
-
<configuration name="asObservable.test.tsx" type="JavaScriptTestRunnerJest" temporary="true" nameIsGenerated="true">
|
|
99
|
-
<node-interpreter value="project" />
|
|
100
|
-
<node-options value="" />
|
|
101
|
-
<jest-package value="$PROJECT_DIR$/node_modules/jest" />
|
|
102
|
-
<working-dir value="$PROJECT_DIR$" />
|
|
103
|
-
<envs />
|
|
104
|
-
<scope-kind value="TEST_FILE" />
|
|
105
|
-
<test-file value="$PROJECT_DIR$/src/__tests__/asObservable.test.tsx" />
|
|
106
|
-
<method v="2" />
|
|
107
|
-
</configuration>
|
|
108
|
-
<configuration name="the returned observable should *not* receive a new value when component is rendered with an unchanged value" type="JavaScriptTestRunnerJest" temporary="true" nameIsGenerated="true">
|
|
109
|
-
<node-interpreter value="project" />
|
|
110
|
-
<node-options value="" />
|
|
111
|
-
<jest-package value="$PROJECT_DIR$/node_modules/jest" />
|
|
112
|
-
<working-dir value="$PROJECT_DIR$" />
|
|
113
|
-
<envs />
|
|
114
|
-
<scope-kind value="TEST" />
|
|
115
|
-
<test-file value="$PROJECT_DIR$/src/__tests__/asObservable.test.tsx" />
|
|
116
|
-
<test-names>
|
|
117
|
-
<test-name value="the returned observable should *not* receive a new value when component is rendered with an unchanged value" />
|
|
118
|
-
</test-names>
|
|
119
|
-
<method v="2" />
|
|
120
|
-
</configuration>
|
|
121
|
-
<configuration name="the returned observable should receive a new value when component is rendered with a new value" type="JavaScriptTestRunnerJest" temporary="true" nameIsGenerated="true">
|
|
122
|
-
<node-interpreter value="project" />
|
|
123
|
-
<node-options value="" />
|
|
124
|
-
<jest-package value="$PROJECT_DIR$/node_modules/jest" />
|
|
125
|
-
<working-dir value="$PROJECT_DIR$" />
|
|
126
|
-
<envs />
|
|
127
|
-
<scope-kind value="TEST" />
|
|
128
|
-
<test-file value="$PROJECT_DIR$/src/__tests__/asObservable.test.tsx" />
|
|
129
|
-
<test-names>
|
|
130
|
-
<test-name value="the returned observable should receive a new value when component is rendered with a new value" />
|
|
131
|
-
</test-names>
|
|
132
|
-
<method v="2" />
|
|
133
|
-
</configuration>
|
|
134
|
-
<configuration name="the returned observable should receive a new value when component is rendered with an unchanged value" type="JavaScriptTestRunnerJest" temporary="true" nameIsGenerated="true">
|
|
135
|
-
<node-interpreter value="project" />
|
|
136
|
-
<node-options value="" />
|
|
137
|
-
<jest-package value="$PROJECT_DIR$/node_modules/jest" />
|
|
138
|
-
<working-dir value="$PROJECT_DIR$" />
|
|
139
|
-
<envs />
|
|
140
|
-
<scope-kind value="TEST" />
|
|
141
|
-
<test-file value="$PROJECT_DIR$/src/__tests__/asObservable.test.tsx" />
|
|
142
|
-
<test-names>
|
|
143
|
-
<test-name value="the returned observable should receive a new value when component is rendered with an unchanged value" />
|
|
144
|
-
</test-names>
|
|
145
|
-
<method v="2" />
|
|
146
|
-
</configuration>
|
|
147
|
-
<configuration name="useAsObservable.test.tsx" type="JavaScriptTestRunnerJest" temporary="true" nameIsGenerated="true">
|
|
148
|
-
<node-interpreter value="project" />
|
|
149
|
-
<node-options value="" />
|
|
150
|
-
<jest-package value="$PROJECT_DIR$/node_modules/jest" />
|
|
151
|
-
<working-dir value="$PROJECT_DIR$" />
|
|
152
|
-
<envs />
|
|
153
|
-
<scope-kind value="TEST_FILE" />
|
|
154
|
-
<test-file value="$PROJECT_DIR$/src/__tests__/useAsObservable.test.tsx" />
|
|
155
|
-
<method v="2" />
|
|
156
|
-
</configuration>
|
|
157
|
-
<configuration name="useObservable.test.tsx" type="JavaScriptTestRunnerJest" nameIsGenerated="true">
|
|
158
|
-
<node-interpreter value="project" />
|
|
159
|
-
<node-options value="" />
|
|
160
|
-
<jest-package value="$PROJECT_DIR$/node_modules/jest" />
|
|
161
|
-
<working-dir value="$PROJECT_DIR$" />
|
|
162
|
-
<envs />
|
|
163
|
-
<scope-kind value="TEST_FILE" />
|
|
164
|
-
<test-file value="$PROJECT_DIR$/src/__tests__/useObservable.test.tsx" />
|
|
165
|
-
<method v="2" />
|
|
166
|
-
</configuration>
|
|
167
|
-
<list>
|
|
168
|
-
<item itemvalue="Jest.All Tests" />
|
|
169
|
-
<item itemvalue="Jest.asObservable.test.tsx" />
|
|
170
|
-
<item itemvalue="Jest.the returned observable should *not* receive a new value when component is rendered with an unchanged value" />
|
|
171
|
-
<item itemvalue="Jest.the returned observable should receive a new value when component is rendered with a new value" />
|
|
172
|
-
<item itemvalue="Jest.the returned observable should receive a new value when component is rendered with an unchanged value" />
|
|
173
|
-
<item itemvalue="Jest.useAsObservable.test.tsx" />
|
|
174
|
-
<item itemvalue="Jest.useObservable.test.tsx" />
|
|
175
|
-
</list>
|
|
176
|
-
<recent_temporary>
|
|
177
|
-
<list>
|
|
178
|
-
<item itemvalue="Jest.useAsObservable.test.tsx" />
|
|
179
|
-
<item itemvalue="Jest.asObservable.test.tsx" />
|
|
180
|
-
<item itemvalue="Jest.the returned observable should receive a new value when component is rendered with a new value" />
|
|
181
|
-
<item itemvalue="Jest.the returned observable should *not* receive a new value when component is rendered with an unchanged value" />
|
|
182
|
-
<item itemvalue="Jest.the returned observable should receive a new value when component is rendered with an unchanged value" />
|
|
183
|
-
</list>
|
|
184
|
-
</recent_temporary>
|
|
185
|
-
</component>
|
|
186
|
-
<component name="RustProjectSettings">
|
|
187
|
-
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
|
|
188
|
-
<option name="version" value="2" />
|
|
189
|
-
</component>
|
|
190
|
-
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
|
191
|
-
<component name="TaskManager">
|
|
192
|
-
<task active="true" id="Default" summary="Default task">
|
|
193
|
-
<changelist id="9f1530e5-3e67-4ff9-b8bc-a40f03478761" name="Default Changelist" comment="" />
|
|
194
|
-
<created>1610996869139</created>
|
|
195
|
-
<option name="number" value="Default" />
|
|
196
|
-
<option name="presentableId" value="Default" />
|
|
197
|
-
<updated>1610996869139</updated>
|
|
198
|
-
</task>
|
|
199
|
-
<servers />
|
|
200
|
-
</component>
|
|
201
|
-
<component name="TypeScriptGeneratedFilesManager">
|
|
202
|
-
<option name="version" value="3" />
|
|
203
|
-
</component>
|
|
204
|
-
<component name="Vcs.Log.Tabs.Properties">
|
|
205
|
-
<option name="TAB_STATES">
|
|
206
|
-
<map>
|
|
207
|
-
<entry key="MAIN">
|
|
208
|
-
<value>
|
|
209
|
-
<State />
|
|
210
|
-
</value>
|
|
211
|
-
</entry>
|
|
212
|
-
</map>
|
|
213
|
-
</option>
|
|
214
|
-
<option name="oldMeFiltersMigrated" value="true" />
|
|
215
|
-
</component>
|
|
216
|
-
<component name="VcsManagerConfiguration">
|
|
217
|
-
<ignored-roots>
|
|
218
|
-
<path value="$PROJECT_DIR$/../../_/parcel-plugin-mdx" />
|
|
219
|
-
<path value="$PROJECT_DIR$/test-concurrent-mode" />
|
|
220
|
-
<path value="$PROJECT_DIR$/test-concurrent-mode2" />
|
|
221
|
-
<path value="$PROJECT_DIR$/website" />
|
|
222
|
-
</ignored-roots>
|
|
223
|
-
</component>
|
|
224
|
-
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
|
225
|
-
<SUITE FILE_PATH="coverage/react_rx$All_Tests.info" NAME="All Tests Coverage Results" MODIFIED="1585859619310" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="JestJavaScriptTestRunnerCoverage" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" />
|
|
226
|
-
<SUITE FILE_PATH="coverage/react_rx$toObservable_test_tsx.info" NAME="toObservable.test.tsx Coverage Results" MODIFIED="1585859575939" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="JestJavaScriptTestRunnerCoverage" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" />
|
|
227
|
-
</component>
|
|
228
|
-
</project>
|
package/jest.config.js
DELETED
package/website/.babelrc
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"presets": [
|
|
3
|
-
"@babel/react",
|
|
4
|
-
"@babel/typescript",
|
|
5
|
-
[
|
|
6
|
-
"@babel/env",
|
|
7
|
-
{
|
|
8
|
-
"targets": {
|
|
9
|
-
"esmodules": true
|
|
10
|
-
},
|
|
11
|
-
"modules": false
|
|
12
|
-
}
|
|
13
|
-
]
|
|
14
|
-
],
|
|
15
|
-
"plugins": [
|
|
16
|
-
"@babel/plugin-proposal-optional-chaining",
|
|
17
|
-
"@babel/plugin-proposal-class-properties",
|
|
18
|
-
"babel-plugin-static-fs",
|
|
19
|
-
"babel-plugin-styled-components"
|
|
20
|
-
]
|
|
21
|
-
}
|
package/website/.prettierrc
DELETED
package/website/README.mdx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
WRONG README
|
package/website/package.json
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react-rx-website",
|
|
3
|
-
"private": true,
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"description": "React rx website",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "NODE_ENV=production webpack --mode=production --config webpack/config.js",
|
|
8
|
-
"watch": "webpack -w --config webpack/config.js",
|
|
9
|
-
"start": "webpack-dev-server --config webpack/config.js",
|
|
10
|
-
"dev": "npm start",
|
|
11
|
-
"postinstall": "cp ../README.md src/pages/Index/ReactRxReadme.md"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [],
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"@babel/core": "^7.10.3",
|
|
16
|
-
"@babel/plugin-proposal-class-properties": "^7.10.1",
|
|
17
|
-
"@babel/plugin-proposal-optional-chaining": "^7.10.3",
|
|
18
|
-
"@babel/plugin-transform-typescript": "^7.10.3",
|
|
19
|
-
"@babel/preset-react": "^7.10.1",
|
|
20
|
-
"@babel/preset-typescript": "^7.10.1",
|
|
21
|
-
"@mdx-js/react": "^1.6.6",
|
|
22
|
-
"@types/babel__core": "^7.1.9",
|
|
23
|
-
"@types/codemirror": "^0.0.96",
|
|
24
|
-
"@types/history": "^4.7.6",
|
|
25
|
-
"@types/mdx-js__react": "^1.5.2",
|
|
26
|
-
"@types/react": "^16.9.41",
|
|
27
|
-
"@types/react-dom": "^16.9.8",
|
|
28
|
-
"@types/styled-components": "^5.1.0",
|
|
29
|
-
"@typescript-eslint/eslint-plugin": "^3.4.0",
|
|
30
|
-
"@typescript-eslint/parser": "^3.4.0",
|
|
31
|
-
"bezier-easing": "^2.1.0",
|
|
32
|
-
"codemirror": "^5.55.0",
|
|
33
|
-
"date-fns": "^2.14.0",
|
|
34
|
-
"eslint": "^7.3.1",
|
|
35
|
-
"eslint-config-prettier": "^6.11.0",
|
|
36
|
-
"eslint-plugin-prettier": "^3.1.4",
|
|
37
|
-
"eslint-plugin-react": "^7.20.0",
|
|
38
|
-
"history": "^5.0.0",
|
|
39
|
-
"jest": "^26.1.0",
|
|
40
|
-
"lodash": "^4.17.15",
|
|
41
|
-
"observable-callback": "^1.0.1",
|
|
42
|
-
"prettier": "2.0.5",
|
|
43
|
-
"react": "^17.0.1",
|
|
44
|
-
"react-codemirror2": "^7.2.1",
|
|
45
|
-
"react-css-burger": "^0.2.0",
|
|
46
|
-
"react-dom": "^17.0.1",
|
|
47
|
-
"react-rx": "1.0.0-beta.4",
|
|
48
|
-
"remark-emoji": "^2.1.0",
|
|
49
|
-
"rimraf": "^3.0.2",
|
|
50
|
-
"rxjs": "^6.5.5",
|
|
51
|
-
"styled-components": "^5.1.1",
|
|
52
|
-
"webpack": "^4.43.0",
|
|
53
|
-
"webpack-cli": "^3.3.12"
|
|
54
|
-
},
|
|
55
|
-
"author": "",
|
|
56
|
-
"license": "ISC",
|
|
57
|
-
"devDependencies": {
|
|
58
|
-
"@babel/preset-env": "^7.10.3",
|
|
59
|
-
"@babel/standalone": "^7.10.3",
|
|
60
|
-
"@mdx-js/loader": "^1.6.6",
|
|
61
|
-
"@mdx-js/mdx": "^1.6.6",
|
|
62
|
-
"@types/lodash": "^4.14.157",
|
|
63
|
-
"@types/node": "^14.0.14",
|
|
64
|
-
"@webhotelier/webpack-fast-refresh": "5.0.1",
|
|
65
|
-
"babel-loader": "^8.1.0",
|
|
66
|
-
"babel-plugin-static-fs": "^3.0.0",
|
|
67
|
-
"babel-plugin-styled-components": "^1.10.7",
|
|
68
|
-
"clean-webpack-plugin": "^3.0.0",
|
|
69
|
-
"copy-webpack-plugin": "^6.0.2",
|
|
70
|
-
"css-loader": "^3.6.0",
|
|
71
|
-
"github-slugger": "^1.3.0",
|
|
72
|
-
"html-loader": "^1.1.0",
|
|
73
|
-
"html-webpack-plugin": "^4.3.0",
|
|
74
|
-
"markdown-toc": "^1.2.0",
|
|
75
|
-
"react-refresh": "0.8.3",
|
|
76
|
-
"remark-slug": "^6.0.0",
|
|
77
|
-
"style-loader": "^1.2.1",
|
|
78
|
-
"ts-loader": "^7.0.5",
|
|
79
|
-
"ts-node": "^8.10.2",
|
|
80
|
-
"tsconfig-paths": "^3.9.0",
|
|
81
|
-
"typescript": "^3.9.5",
|
|
82
|
-
"webpack-dev-server": "^3.11.0"
|
|
83
|
-
}
|
|
84
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
declare module '*.md' {
|
|
2
|
-
const MDXComponent: (props: any) => JSX.Element
|
|
3
|
-
export default MDXComponent
|
|
4
|
-
export {MDXComponent as Toc}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare module '*.mdx' {
|
|
8
|
-
const MDXComponent: (props: any) => JSX.Element
|
|
9
|
-
export default MDXComponent
|
|
10
|
-
export {MDXComponent as Toc}
|
|
11
|
-
}
|
package/website/src/App.tsx
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
import {createGlobalStyle} from 'styled-components'
|
|
3
|
-
import {rxComponent} from 'react-rx'
|
|
4
|
-
import {map} from 'rxjs/operators'
|
|
5
|
-
import {COLORS, media} from './theme'
|
|
6
|
-
import {pageTransition$} from './datastores/pageTransition'
|
|
7
|
-
|
|
8
|
-
const GlobalStyle = createGlobalStyle`
|
|
9
|
-
body {
|
|
10
|
-
${media.between('xsmall', 'small')} {
|
|
11
|
-
font-size: 12px;
|
|
12
|
-
}
|
|
13
|
-
${media.between('small', 'medium')} {
|
|
14
|
-
font-size: 14px;
|
|
15
|
-
}
|
|
16
|
-
${media.greaterThan('medium')} {
|
|
17
|
-
font-size: 16px;
|
|
18
|
-
}
|
|
19
|
-
${media.greaterThan('large')} {
|
|
20
|
-
font-size: 18px;
|
|
21
|
-
}
|
|
22
|
-
padding: 0;
|
|
23
|
-
margin: 0;
|
|
24
|
-
background: ${COLORS.background};
|
|
25
|
-
color: ${COLORS.text};
|
|
26
|
-
font-family: Inter, -apple-system, system-ui, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
|
|
27
|
-
'Droid Sans', 'Helvetica Neue', 'Fira Sans', system-ui, sans-serif;
|
|
28
|
-
font-size: 1.125rem;
|
|
29
|
-
overflow-y: scroll;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
h1::before, h2::before, h3::before, h4::before {
|
|
33
|
-
display: block;
|
|
34
|
-
content: " ";
|
|
35
|
-
visibility: hidden;
|
|
36
|
-
pointer-events: none;
|
|
37
|
-
}
|
|
38
|
-
h2::before, h3::before, h4::before {
|
|
39
|
-
margin-top: -6em;
|
|
40
|
-
height: 6em;
|
|
41
|
-
}
|
|
42
|
-
h1::before {
|
|
43
|
-
margin-top: -6em;
|
|
44
|
-
height: 6em;
|
|
45
|
-
}
|
|
46
|
-
a:link,
|
|
47
|
-
a:visited {
|
|
48
|
-
color: ${COLORS.link};
|
|
49
|
-
text-decoration: none;
|
|
50
|
-
}
|
|
51
|
-
`
|
|
52
|
-
|
|
53
|
-
export const App = rxComponent(
|
|
54
|
-
pageTransition$.pipe(
|
|
55
|
-
map((transition) => {
|
|
56
|
-
return (
|
|
57
|
-
<>
|
|
58
|
-
<GlobalStyle />
|
|
59
|
-
{transition.component ? (
|
|
60
|
-
<transition.component />
|
|
61
|
-
) : (
|
|
62
|
-
<div>Loading…</div>
|
|
63
|
-
)}
|
|
64
|
-
</>
|
|
65
|
-
)
|
|
66
|
-
})
|
|
67
|
-
)
|
|
68
|
-
)
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import {Link} from './Link'
|
|
2
|
-
import * as React from 'react'
|
|
3
|
-
import styled from 'styled-components'
|
|
4
|
-
import {rxComponent} from 'react-rx'
|
|
5
|
-
import {pages} from '../pages/pages'
|
|
6
|
-
|
|
7
|
-
import {map} from 'rxjs/operators'
|
|
8
|
-
import {GithubLogo} from './logos/Github'
|
|
9
|
-
import {COLORS} from '../theme'
|
|
10
|
-
import {ReactRxLogo} from './logos/ReactRxLogo'
|
|
11
|
-
import {pageTransition$} from '../datastores/pageTransition'
|
|
12
|
-
import {omit} from 'lodash'
|
|
13
|
-
|
|
14
|
-
const StyledHeader = styled.header`
|
|
15
|
-
z-index: 2000;
|
|
16
|
-
position: fixed;
|
|
17
|
-
top: 0;
|
|
18
|
-
left: 0;
|
|
19
|
-
right: 0;
|
|
20
|
-
padding-bottom: 0;
|
|
21
|
-
background: ${COLORS.header.background};
|
|
22
|
-
a,
|
|
23
|
-
a:link,
|
|
24
|
-
a:visited {
|
|
25
|
-
color: ${COLORS.header.text};
|
|
26
|
-
}
|
|
27
|
-
`
|
|
28
|
-
|
|
29
|
-
const HeaderInner = styled.div`
|
|
30
|
-
display: flex;
|
|
31
|
-
flex-direction: row;
|
|
32
|
-
justify-content: space-between;
|
|
33
|
-
align-items: center;
|
|
34
|
-
height: 5em;
|
|
35
|
-
padding: 0.5em 1em 0.5em 1em;
|
|
36
|
-
background-color: ${COLORS.header.background};
|
|
37
|
-
`
|
|
38
|
-
|
|
39
|
-
const LinkWrapper = styled.div`
|
|
40
|
-
color: #efefef;
|
|
41
|
-
padding: 0.5em 1.2em 0.5em 0;
|
|
42
|
-
`
|
|
43
|
-
|
|
44
|
-
const omitProps = <T extends React.ComponentType>(
|
|
45
|
-
Component: T,
|
|
46
|
-
omitProps: string[]
|
|
47
|
-
) => (props: React.ComponentProps<T>) => {
|
|
48
|
-
const omitted: any = omit(props, omitProps)
|
|
49
|
-
return <Component {...omitted} />
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const PageLink = styled(omitProps(Link, ['isActive', 'isTransitioningTo']))<{
|
|
53
|
-
isActive: boolean
|
|
54
|
-
isTransitioningTo: boolean
|
|
55
|
-
}>`
|
|
56
|
-
display: block;
|
|
57
|
-
color: ${COLORS.text};
|
|
58
|
-
font-size: 1em;
|
|
59
|
-
&:link,
|
|
60
|
-
&:visited {
|
|
61
|
-
color: ${COLORS.text};
|
|
62
|
-
text-decoration: ${(props) =>
|
|
63
|
-
(props.isActive || props.isTransitioningTo) && `underline`};
|
|
64
|
-
text-decoration-style: ${(props) => props.isTransitioningTo && `wavy`};
|
|
65
|
-
}
|
|
66
|
-
`
|
|
67
|
-
|
|
68
|
-
const LogoWrapper = styled.div`
|
|
69
|
-
font-family: Roboto, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica,
|
|
70
|
-
Arial, 'Lucida Grande', sans-serif;
|
|
71
|
-
-webkit-font-smoothing: antialiased;
|
|
72
|
-
font-weight: bold;
|
|
73
|
-
font-size: 1.3em;
|
|
74
|
-
display: flex;
|
|
75
|
-
flex-grow: 1;
|
|
76
|
-
align-items: center;
|
|
77
|
-
`
|
|
78
|
-
const Logo = () => (
|
|
79
|
-
<LogoWrapper>
|
|
80
|
-
<Link href="/">
|
|
81
|
-
<ReactRxLogo size="2em" style={{paddingRight: '0.4em'}} />
|
|
82
|
-
ReactRx
|
|
83
|
-
</Link>
|
|
84
|
-
</LogoWrapper>
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
export const Header = rxComponent((page$) =>
|
|
88
|
-
pageTransition$.pipe(
|
|
89
|
-
map((transitionState) => (
|
|
90
|
-
<StyledHeader>
|
|
91
|
-
<HeaderInner>
|
|
92
|
-
<Logo />
|
|
93
|
-
{pages
|
|
94
|
-
.filter((page) => page.id !== 'home')
|
|
95
|
-
.map((page) => {
|
|
96
|
-
return (
|
|
97
|
-
<LinkWrapper key={page.id}>
|
|
98
|
-
<PageLink
|
|
99
|
-
href={page.route}
|
|
100
|
-
isTransitioningTo={
|
|
101
|
-
transitionState.isTransitioning &&
|
|
102
|
-
transitionState.next === page
|
|
103
|
-
}
|
|
104
|
-
isActive={transitionState.current === page}
|
|
105
|
-
>
|
|
106
|
-
{page.title}
|
|
107
|
-
</PageLink>
|
|
108
|
-
</LinkWrapper>
|
|
109
|
-
)
|
|
110
|
-
})}
|
|
111
|
-
<a href="https://github.com/sanity-io/react-rx">
|
|
112
|
-
<GithubLogo style={{color: '#fff'}} height="25" width="25" />
|
|
113
|
-
</a>
|
|
114
|
-
</HeaderInner>
|
|
115
|
-
</StyledHeader>
|
|
116
|
-
))
|
|
117
|
-
)
|
|
118
|
-
)
|