Skip to content

Commit

Permalink
Merge pull request #4058 from reduxjs/feature/4x-remove-legacy-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson authored Apr 2, 2021
2 parents f3680b5 + d29cbfa commit 9a1d065
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/size.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
- uses: preactjs/compressed-size-action@v1
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
pattern: './{dist,es,lib}/*.js'
pattern: './{dist,es,lib}/*.{js,mjs}'
8 changes: 6 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/// <reference types="symbol-observable" />

/**
* An *action* is a plain object that represents an intention to change the
* state. Actions are the only way to get data into the store. Any data,
Expand Down Expand Up @@ -224,6 +222,12 @@ export interface Unsubscribe {
(): void
}

declare global {
interface SymbolConstructor {
readonly observable: symbol
}
}

/**
* A minimal observable of state changes.
* For more information, see the observable proposal:
Expand Down
9 changes: 3 additions & 6 deletions package-lock.json

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

7 changes: 0 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
"examples:test": "cross-env CI=true babel-node examples/testAll.js"
},
"dependencies": {
"loose-envify": "^1.4.0",
"symbol-observable": "^2.0.3",
"@babel/runtime": "^7.9.2"
},
"devDependencies": {
Expand Down Expand Up @@ -102,11 +100,6 @@
]
}
],
"browserify": {
"transform": [
"loose-envify"
]
},
"jest": {
"testRegex": "(/test/.*\\.spec\\.[tj]s)$",
"coverageProvider": "v8"
Expand Down
2 changes: 1 addition & 1 deletion src/createStore.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $$observable from 'symbol-observable'
import $$observable from './utils/symbol-observable'

import ActionTypes from './utils/actionTypes'
import isPlainObject from './utils/isPlainObject'
Expand Down
3 changes: 3 additions & 0 deletions src/utils/symbol-observable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Inlined version of the `symbol-observable` polyfill
export default (() =>
(typeof Symbol === 'function' && Symbol.observable) || '@@observable')()
7 changes: 5 additions & 2 deletions test/createStore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import {
import * as reducers from './helpers/reducers'
import { from } from 'rxjs'
import { map } from 'rxjs/operators'
import $$observable from 'symbol-observable'
import $$observable from '../src/utils/symbol-observable'

describe('createStore', () => {
it('exposes the public API', () => {
const store = createStore(combineReducers(reducers))
const methods = Object.keys(store)

// Since switching to internal Symbol.observable impl, it will show up as a key in node env
// So we filter it out
const methods = Object.keys(store).filter((key) => key !== $$observable)

expect(methods.length).toBe(4)
expect(methods).toContain('subscribe')
Expand Down
3 changes: 2 additions & 1 deletion test/typescript/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
Unsubscribe,
Observer,
} from 'redux'
import 'symbol-observable'
// @ts-ignore
import $$observable from '../src/utils/symbol-observable'

type BrandedString = string & { _brand: 'type' }
const brandedString = 'a string' as BrandedString
Expand Down

0 comments on commit 9a1d065

Please # to comment.