react-rx 1.0.0-beta.4 → 1.0.1

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.
Files changed (171) hide show
  1. package/.idea/vcs.xml +0 -3
  2. package/.idea/workspace.xml +18 -15
  3. package/dist/cjs/WithObservable.d.ts +3 -3
  4. package/dist/cjs/WithObservable.js +3 -3
  5. package/dist/cjs/index.d.ts +3 -2
  6. package/dist/cjs/index.js +9 -6
  7. package/dist/cjs/reactiveComponent.d.ts +6 -6
  8. package/dist/cjs/reactiveComponent.js +7 -26
  9. package/dist/cjs/useAsObservable.d.ts +1 -0
  10. package/dist/cjs/useAsObservable.js +10 -33
  11. package/dist/cjs/useIsomorphicEffect.d.ts +2 -0
  12. package/dist/cjs/useIsomorphicEffect.js +5 -0
  13. package/dist/cjs/useObservable.d.ts +6 -6
  14. package/dist/cjs/useObservable.js +8 -26
  15. package/dist/cjs/useObservableCallback.d.ts +3 -0
  16. package/dist/cjs/useObservableCallback.js +24 -0
  17. package/dist/cjs/useWithObservable.d.ts +9 -0
  18. package/dist/cjs/useWithObservable.js +11 -0
  19. package/dist/cjs/utils.d.ts +3 -3
  20. package/dist/cjs/utils.js +8 -27
  21. package/dist/cjs/withPropsStream.js +3 -3
  22. package/dist/es2015/WithObservable.d.ts +3 -3
  23. package/dist/es2015/index.d.ts +3 -2
  24. package/dist/es2015/index.js +4 -2
  25. package/dist/es2015/reactiveComponent.d.ts +6 -6
  26. package/dist/es2015/reactiveComponent.js +5 -5
  27. package/dist/es2015/useAsObservable.d.ts +1 -0
  28. package/dist/es2015/useAsObservable.js +10 -14
  29. package/dist/es2015/useIsomorphicEffect.d.ts +2 -0
  30. package/dist/es2015/useIsomorphicEffect.js +2 -0
  31. package/dist/es2015/useObservable.d.ts +6 -6
  32. package/dist/es2015/useObservable.js +8 -7
  33. package/dist/es2015/useObservableCallback.d.ts +3 -0
  34. package/dist/es2015/useObservableCallback.js +19 -0
  35. package/dist/es2015/useWithObservable.d.ts +9 -0
  36. package/dist/es2015/useWithObservable.js +7 -0
  37. package/dist/es2015/utils.d.ts +3 -3
  38. package/dist/es2015/utils.js +5 -5
  39. package/dist/esm/WithObservable.d.ts +3 -3
  40. package/dist/esm/index.d.ts +3 -2
  41. package/dist/esm/index.js +4 -2
  42. package/dist/esm/reactiveComponent.d.ts +6 -6
  43. package/dist/esm/reactiveComponent.js +5 -5
  44. package/dist/esm/useAsObservable.d.ts +1 -0
  45. package/dist/esm/useAsObservable.js +10 -14
  46. package/dist/esm/useIsomorphicEffect.d.ts +2 -0
  47. package/dist/esm/useIsomorphicEffect.js +2 -0
  48. package/dist/esm/useObservable.d.ts +6 -6
  49. package/dist/esm/useObservable.js +8 -7
  50. package/dist/esm/useObservableCallback.d.ts +3 -0
  51. package/dist/esm/useObservableCallback.js +20 -0
  52. package/dist/esm/useWithObservable.d.ts +9 -0
  53. package/dist/esm/useWithObservable.js +7 -0
  54. package/dist/esm/utils.d.ts +3 -3
  55. package/dist/esm/utils.js +5 -5
  56. package/package.json +3 -3
  57. package/src/WithObservable.tsx +4 -3
  58. package/src/index.ts +5 -4
  59. package/src/reactiveComponent.ts +24 -18
  60. package/src/useAsObservable.ts +18 -8
  61. package/src/useIsomorphicEffect.ts +3 -0
  62. package/src/useObservable.ts +17 -19
  63. package/src/useObservableCallback.ts +30 -0
  64. package/src/useWithObservable.ts +23 -0
  65. package/src/utils.ts +8 -8
  66. package/jest.config.js +0 -5
  67. package/website/.babelrc +0 -21
  68. package/website/.prettierrc +0 -7
  69. package/website/README.mdx +0 -1
  70. package/website/package.json +0 -84
  71. package/website/src/@types/babel.d.ts +0 -4
  72. package/website/src/@types/mdx.d.ts +0 -11
  73. package/website/src/@types/react-css-burger.d.ts +0 -4
  74. package/website/src/App.tsx +0 -68
  75. package/website/src/components/Header.tsx +0 -118
  76. package/website/src/components/Link.tsx +0 -18
  77. package/website/src/components/LoadPage.tsx +0 -60
  78. package/website/src/components/Sidebar.tsx +0 -88
  79. package/website/src/components/logos/Github.tsx +0 -10
  80. package/website/src/components/logos/React.tsx +0 -27
  81. package/website/src/components/logos/ReactRxLogo.tsx +0 -39
  82. package/website/src/components/logos/RxJs.tsx +0 -69
  83. package/website/src/components/repl/Checkerboard.tsx +0 -25
  84. package/website/src/components/repl/CodeBlock.tsx +0 -147
  85. package/website/src/components/repl/CodeMirror.tsx +0 -37
  86. package/website/src/components/repl/CodeMirrorMode.tsx +0 -67
  87. package/website/src/components/repl/EvalCode.tsx +0 -55
  88. package/website/src/components/repl/Prelude.tsx +0 -50
  89. package/website/src/components/repl/ShowError.tsx +0 -27
  90. package/website/src/components/repl/codemirror-lib.ts +0 -8
  91. package/website/src/components/repl/codemirror-theme.css +0 -131
  92. package/website/src/components/repl/compile/babel.ts +0 -21
  93. package/website/src/components/repl/eval/evalCallback.ts +0 -27
  94. package/website/src/components/repl/eval/evalCode.ts +0 -7
  95. package/website/src/components/repl/eval/evalExpression.ts +0 -4
  96. package/website/src/components/repl/eval/evalReactDomRender.ts +0 -23
  97. package/website/src/components/repl/index.ts +0 -1
  98. package/website/src/components/repl/runMode.ts +0 -42
  99. package/website/src/datastores/location.ts +0 -14
  100. package/website/src/datastores/page.ts +0 -11
  101. package/website/src/datastores/pageTransition.ts +0 -97
  102. package/website/src/entries/main.css +0 -2
  103. package/website/src/entries/main.tsx +0 -6
  104. package/website/src/examples/FizzBuzz/FizzBuzzExample.tsx +0 -39
  105. package/website/src/examples/FizzBuzz/index.tsx +0 -9
  106. package/website/src/examples/_utils/globalScope.ts +0 -45
  107. package/website/src/examples/animation/AnimationExample.tsx +0 -152
  108. package/website/src/examples/animation/easings.ts +0 -0
  109. package/website/src/examples/animation/index.tsx +0 -15
  110. package/website/src/examples/context/Context.example.jsx +0 -67
  111. package/website/src/examples/context/index.tsx +0 -9
  112. package/website/src/examples/errors/Errors.example.jsx +0 -69
  113. package/website/src/examples/errors/index.tsx +0 -9
  114. package/website/src/examples/event-handlers/EventHandlersExample.tsx +0 -48
  115. package/website/src/examples/event-handlers/index.tsx +0 -9
  116. package/website/src/examples/fetch/FetchExample.jsx +0 -43
  117. package/website/src/examples/fetch/a.txt +0 -1
  118. package/website/src/examples/fetch/b.txt +0 -1
  119. package/website/src/examples/fetch/index.tsx +0 -9
  120. package/website/src/examples/form-data/FormDataExample.jsx +0 -119
  121. package/website/src/examples/form-data/index.tsx +0 -12
  122. package/website/src/examples/form-data/storage.ts +0 -27
  123. package/website/src/examples/forward-ref/ForwardRefExample.tsx +0 -55
  124. package/website/src/examples/forward-ref/index.tsx +0 -9
  125. package/website/src/examples/hello-world/HelloWorld.example.jsx +0 -6
  126. package/website/src/examples/hello-world/index.tsx +0 -9
  127. package/website/src/examples/hooks-interop/HooksInterop.example.tsx +0 -42
  128. package/website/src/examples/hooks-interop/index.tsx +0 -9
  129. package/website/src/examples/passthrough-props/PassThroughPropsExample.jsx +0 -57
  130. package/website/src/examples/passthrough-props/index.tsx +0 -11
  131. package/website/src/examples/reactive-state/ReactiveState.example.jsx +0 -43
  132. package/website/src/examples/reactive-state/index.ts +0 -9
  133. package/website/src/examples/readme-examples/README.mdx +0 -0
  134. package/website/src/examples/readme-examples/index.ts +0 -11
  135. package/website/src/examples/shared-state/SharedState.example.tsx +0 -59
  136. package/website/src/examples/shared-state/index.tsx +0 -9
  137. package/website/src/examples/simple/Counter.example.tsx +0 -14
  138. package/website/src/examples/simple/index.tsx +0 -9
  139. package/website/src/examples/sync/Sync.example.tsx +0 -9
  140. package/website/src/examples/sync/index.tsx +0 -9
  141. package/website/src/examples/tick/TickExample.jsx +0 -51
  142. package/website/src/examples/tick/index.ts +0 -9
  143. package/website/src/examples/todo-app/TodoApp.example.tsx +0 -88
  144. package/website/src/examples/todo-app/index.tsx +0 -12
  145. package/website/src/examples/todo-app/storage.ts +0 -27
  146. package/website/src/examples/use-element/UseElementExample.tsx +0 -70
  147. package/website/src/examples/use-element/index.tsx +0 -9
  148. package/website/src/examples/use-observable/search/SearchExample.tsx +0 -82
  149. package/website/src/examples/use-observable/search/index.tsx +0 -8
  150. package/website/src/examples/use-observable/use-observable/UseObservableExample.tsx +0 -70
  151. package/website/src/examples/use-observable/use-observable/index.tsx +0 -9
  152. package/website/src/index.html +0 -10
  153. package/website/src/mdx-components.tsx +0 -74
  154. package/website/src/pages/Api/Api.mdx +0 -134
  155. package/website/src/pages/Api/ApiPage.tsx +0 -25
  156. package/website/src/pages/Examples/Examples.tsx +0 -105
  157. package/website/src/pages/Examples/ExamplesPage.tsx +0 -13
  158. package/website/src/pages/Guide/Guide.mdx +0 -275
  159. package/website/src/pages/Guide/GuidePage.tsx +0 -25
  160. package/website/src/pages/Index/IndexPage.tsx +0 -50
  161. package/website/src/pages/Index/ReactRxReadme.md +0 -20
  162. package/website/src/pages/NotFound.tsx +0 -3
  163. package/website/src/pages/pages.ts +0 -46
  164. package/website/src/pages/styles.tsx +0 -24
  165. package/website/src/theme.ts +0 -61
  166. package/website/src/utils/parseCodeFenceHeader.ts +0 -32
  167. package/website/tsconfig.json +0 -30
  168. package/website/vercel.json +0 -4
  169. package/website/webpack/config.js +0 -5
  170. package/website/webpack/createConfig.js +0 -95
  171. package/website/webpack/mdx-toc-loader.js +0 -38
@@ -1,50 +0,0 @@
1
- import * as React from 'react'
2
- import {Header} from '../../components/Header'
3
- import {MDXProvider} from '@mdx-js/react'
4
- import ReactRxReadme from './ReactRxReadme.md'
5
- import {components} from '../../mdx-components'
6
- import {ReactRxLogo} from '../../components/logos/ReactRxLogo'
7
- import styled from 'styled-components'
8
- import {COLORS} from '../../theme'
9
-
10
- const Content = styled.div`
11
- margin-top: 5em;
12
- `
13
- const ContentInner = styled.div`
14
- padding: 1em 1em;
15
- `
16
- const Cover = styled.div`
17
- background: ${COLORS.shadow};
18
- color: ${COLORS.background};
19
- padding-top: 2em;
20
- font-size: 2em;
21
- display: flex;
22
- flex-direction: row;
23
- justify-content: center;
24
- h1 {
25
- padding: 0 0 0 0.1em;
26
- }
27
- `
28
-
29
- const Subsection = styled.div`
30
- display: flex;
31
- flex-direction: column;
32
- `
33
- export const IndexPage = () => (
34
- <>
35
- <Header />
36
- <Content>
37
- <Cover>
38
- <ReactRxLogo size="4em" />
39
- <h1>ReactRx</h1>
40
- </Cover>
41
- <ContentInner>
42
- <Subsection>
43
- <MDXProvider components={components}>
44
- <ReactRxReadme />
45
- </MDXProvider>
46
- </Subsection>
47
- </ContentInner>
48
- </Content>
49
- </>
50
- )
@@ -1,20 +0,0 @@
1
- > Hooks and utilities for combining React with RxJS Observables
2
-
3
- Features:
4
-
5
- - Works well with Observables emitting values synchronously. You don't pay the re-render-on-mount tax.
6
- - Lightweight. Implemented on top of a small React Hook based core.
7
- - Full TypeScript support.
8
-
9
- This package offers two slightly different utilities for working with RxJS and React:
10
-
11
- - A set of utilities for creating _Reactive components_
12
- - A set of React hooks for using with observables with React
13
-
14
- Although they share a lot of similarities, and reactiveComponent is built on top of `useObservable` are not intended to be used together inside the same component as they represent two different programming styles.
15
-
16
- ---
17
-
18
- - [Reactive components](https://react-rx.dev/guide#reactive-components)
19
- - [Observable hooks](https://react-rx.dev/guide#observable-hooks)
20
- - [Code examples](https://react-rx.dev/examples)
@@ -1,3 +0,0 @@
1
- import React from 'react'
2
-
3
- export const NotFoundPage = () => <h2>Not found!</h2>
@@ -1,46 +0,0 @@
1
- import {NotFoundPage} from './NotFound'
2
-
3
- export interface Page {
4
- id: string
5
- title: string
6
- route: string
7
- load: () => Promise<React.ComponentType<any>>
8
- }
9
-
10
- function get<T extends {}, K extends keyof T>(key: K): (res: T) => T[K] {
11
- return (res: T) => res[key]
12
- }
13
-
14
- export const pages: Page[] = [
15
- {
16
- id: 'home',
17
- title: 'Home',
18
- route: '/',
19
- load: () => import('./Index/IndexPage').then(get('IndexPage'))
20
- },
21
- {
22
- id: 'guide',
23
- title: 'Guide',
24
- route: '/guide',
25
- load: () => import('./Guide/GuidePage').then(get('GuidePage'))
26
- },
27
- {
28
- id: 'api',
29
- title: 'API',
30
- route: '/api',
31
- load: () => import('./Api/ApiPage').then(get('ApiPage'))
32
- },
33
- {
34
- id: 'examples',
35
- title: 'Examples',
36
- route: '/examples',
37
- load: () => import('./Examples/ExamplesPage').then(get('ExamplesPage'))
38
- }
39
- ]
40
-
41
- export const NOT_FOUND: Page = {
42
- id: 'not-found',
43
- title: 'Not found',
44
- route: '',
45
- load: () => Promise.resolve(NotFoundPage)
46
- }
@@ -1,24 +0,0 @@
1
- import styled from 'styled-components'
2
- import * as React from 'react'
3
-
4
- export const Container = styled.div`
5
- margin-top: 7em;
6
- display: flex;
7
- flex-direction: row;
8
- `
9
-
10
- export const ContentWrapper = styled.div`
11
- width: 100%;
12
- margin: 0;
13
- `
14
-
15
- export const ContentInner = styled.div`
16
- padding: 0 1em;
17
- `
18
- export const Content = (props: {children: React.ReactNode}) => {
19
- return (
20
- <ContentWrapper>
21
- <ContentInner>{props.children}</ContentInner>
22
- </ContentWrapper>
23
- )
24
- }
@@ -1,61 +0,0 @@
1
- const SIZES = {
2
- xsmall: {min: 0, max: 599},
3
- small: {min: 600, max: 779},
4
- medium: {min: 780, max: 979},
5
- large: {min: 980, max: 1279},
6
- xlarge: {min: 1280, max: 1339},
7
- xxlarge: {min: 1340, max: Infinity}
8
- }
9
-
10
- export type Size = keyof typeof SIZES
11
-
12
- export const media = {
13
- between(smallKey: Size, largeKey: Size, excludeLarge = false) {
14
- if (excludeLarge) {
15
- return `@media (min-width: ${
16
- SIZES[smallKey].min
17
- }px) and (max-width: ${SIZES[largeKey].min - 1}px)`
18
- } else {
19
- if (SIZES[largeKey].max === Infinity) {
20
- return `@media (min-width: ${SIZES[smallKey].min}px)`
21
- } else {
22
- return `@media (min-width: ${SIZES[smallKey].min}px) and (max-width: ${SIZES[largeKey].max}px)`
23
- }
24
- }
25
- },
26
-
27
- greaterThan(key: Size) {
28
- return `@media (min-width: ${SIZES[key].min}px)`
29
- },
30
-
31
- lessThan(key: Size) {
32
- return `@media (max-width: ${SIZES[key].min - 1}px)`
33
- },
34
-
35
- size(key: Size) {
36
- const size = SIZES[key]
37
-
38
- if (size.min == null) {
39
- return media.lessThan(key)
40
- } else if (size.max == null) {
41
- return media.greaterThan(key)
42
- } else {
43
- return media.between(key, key)
44
- }
45
- }
46
- }
47
-
48
- const PRIMARY = '#d9376e'
49
- const LIGHT = '#eff0f3'
50
- export const COLORS = {
51
- header: {
52
- background: PRIMARY,
53
- text: LIGHT
54
- },
55
- background: LIGHT,
56
- text: '#2a2a2a',
57
- link: PRIMARY,
58
- secondary: '#ff8e3c',
59
- tertiary: '#ff8e3c',
60
- shadow: '#444'
61
- }
@@ -1,32 +0,0 @@
1
- import {flatten, range, uniq} from 'lodash'
2
-
3
- const regex = /^([a-z0-9\s_-]+)({([0-9,-]+)})*/
4
-
5
- function isNum(v: any) {
6
- return !isNaN(v)
7
- }
8
-
9
- export function parseCodeFenceHeader(header: string): [string, number[]?] {
10
- const match = regex.exec(header)
11
- if (!match) {
12
- throw new Error(`Unparseable code fence header: ${header}`)
13
- }
14
- const [, lang, , range] = match
15
-
16
- return range ? [lang, parseRange(range)] : [lang]
17
- }
18
-
19
- function parseRange(nums: string) {
20
- return uniq(flatten(nums.split(',').map(expandRange))).filter(isNum)
21
- }
22
-
23
- function expandRange(rangeStr: string) {
24
- if (rangeStr.includes('-')) {
25
- const numRange = rangeStr
26
- .split('-')
27
- .map(n => Number(n))
28
- .sort()
29
- return range(numRange[numRange.length - 1], numRange[0])
30
- }
31
- return [Number(rangeStr)]
32
- }
@@ -1,30 +0,0 @@
1
- {
2
- "//": "NOTE: TypeScript is only used for typechecking, not transpiling as that's handled by babel",
3
- "include": [
4
- "src/**/*"
5
- ],
6
- "exclude": [
7
- "node_modules/**/*"
8
- ],
9
- "compilerOptions": {
10
- "types": [
11
- "./webpack/type-stubs.d.ts"
12
- ],
13
- "strict": true,
14
- "forceConsistentCasingInFileNames": true,
15
- "noEmit": true,
16
- "lib": [
17
- "dom",
18
- "ES2015"
19
- ],
20
- "target": "es2015",
21
- "moduleResolution": "node",
22
- "module": "esnext",
23
- "esModuleInterop": true,
24
- "skipLibCheck": true,
25
- "jsx": "preserve",
26
- "allowJs": true,
27
- "resolveJsonModule": true,
28
- "isolatedModules": true
29
- }
30
- }
@@ -1,4 +0,0 @@
1
- {
2
- "version": 2,
3
- "routes": [{"handle": "filesystem"}, {"src": "/.*", "dest": "/index.html"}]
4
- }
@@ -1,5 +0,0 @@
1
- const createConfig = require('./createConfig')
2
-
3
- const env = process.env.NODE_ENV === 'production' ? 'production' : 'development'
4
-
5
- module.exports = createConfig(env)
@@ -1,95 +0,0 @@
1
- const path = require('path')
2
- const CopyPlugin = require('copy-webpack-plugin')
3
- const HtmlWebpackPlugin = require('html-webpack-plugin')
4
- const webpack = require('webpack')
5
- const {CleanWebpackPlugin} = require('clean-webpack-plugin')
6
-
7
- module.exports = function createConfig(env) {
8
- return {
9
- mode: env,
10
- entry: './src/entries/main.tsx',
11
- output: {
12
- path: path.resolve(__dirname, '..', 'public'),
13
- filename: '[name]-[hash].js'
14
- },
15
- resolve: {
16
- extensions: ['.tsx', '.ts', '.js']
17
- },
18
- plugins: [
19
- new CleanWebpackPlugin(),
20
- env === 'development' && new webpack.ProgressPlugin(),
21
- new CopyPlugin({
22
- patterns: ['a', 'b'].map((n) => ({
23
- from: `src/examples/fetch/${n}.txt`,
24
- to: `${n}.txt`
25
- }))
26
- }),
27
- new HtmlWebpackPlugin({
28
- template: 'src/index.html',
29
- inject: true
30
- })
31
- ].filter(Boolean),
32
- node: {
33
- global: true,
34
- fs: 'empty',
35
- __filename: 'mock',
36
- __dirname: 'mock'
37
- },
38
- module: {
39
- rules: [
40
- {
41
- test: /\.([tj])sx?$/,
42
- use: 'babel-loader',
43
- exclude: /node_modules/
44
- },
45
- {
46
- test: /\.mdx?$/,
47
- use: ['babel-loader', path.resolve(__dirname, './mdx-toc-loader.js')]
48
- },
49
- {
50
- test: /\.html$/,
51
- use: 'html-loader'
52
- },
53
- {
54
- test: /\.css$/i,
55
- use: ['style-loader', 'css-loader']
56
- }
57
- ]
58
- },
59
- ...(env === 'development' && {
60
- devServer: {
61
- port: 3000,
62
- host: '0.0.0.0',
63
- historyApiFallback: true,
64
- disableHostCheck: true
65
- }
66
- }),
67
- devtool: env === 'development' ? 'source-map' : false,
68
- ...(env === 'production' && {
69
- optimization: {
70
- usedExports: true,
71
- minimize: true,
72
- splitChunks: {
73
- chunks: 'async',
74
- minSize: 30000,
75
- maxSize: 0,
76
- minChunks: 1,
77
- maxAsyncRequests: 6,
78
- maxInitialRequests: 4,
79
- automaticNameDelimiter: '~',
80
- cacheGroups: {
81
- defaultVendors: {
82
- test: /[\\/]node_modules[\\/]/,
83
- priority: -10
84
- },
85
- default: {
86
- minChunks: 2,
87
- priority: -20,
88
- reuseExistingChunk: true
89
- }
90
- }
91
- }
92
- }
93
- })
94
- }
95
- }
@@ -1,38 +0,0 @@
1
- const mdx = require('@mdx-js/mdx')
2
- const toc = require('markdown-toc')
3
- const slug = require('remark-slug')
4
- const ghSlugger = require('github-slugger')
5
- const emoji = require('remark-emoji')
6
-
7
- const slugify = ghSlugger()
8
-
9
- module.exports = async function MdxTocLoader(src) {
10
- const callback = this.async()
11
-
12
- if (!callback) {
13
- return
14
- }
15
-
16
- const mdxConfig = {
17
- skipExport: true,
18
- remarkPlugins: [emoji, slug]
19
- }
20
-
21
- const tocResult = toc(src, {slugify})
22
-
23
- const compiled = mdx(src, mdxConfig)
24
- const compiledToc = mdx(tocResult.content, mdxConfig)
25
-
26
- const code = `/* @jsx mdx */
27
- import React from 'react';
28
- import { mdx } from '@mdx-js/react'
29
- export default ${iife(await compiled)};
30
- export const Toc = ${iife(await compiledToc)}
31
- `
32
- return callback(null, code)
33
- }
34
-
35
- function iife(body) {
36
- return `(function() {${body}
37
- return MDXContent})()`
38
- }