Skip to content

Commit ce59676

Browse files
committed
switch to react-broadcast
1 parent eb8a4ef commit ce59676

File tree

8 files changed

+27
-21
lines changed

8 files changed

+27
-21
lines changed

modules/Link.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { PropTypes } from 'react'
2-
import { LocationSubscriber } from './locationEmission'
2+
import { LocationSubscriber } from './locationBroadcast'
33
import {
44
routerContext as routerContextType
55
} from './PropTypes'

modules/Match.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { PropTypes } from 'react'
22
import MatchProvider from './MatchProvider'
33
import matchPattern from './matchPattern'
4-
import { LocationSubscriber } from './locationEmission'
4+
import { LocationSubscriber } from './locationBroadcast'
55

66
class RegisterMatch extends React.Component {
77
static contextTypes = {

modules/StaticRouter.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { PropTypes } from 'react'
22
import { stringify, parse as parseQueryString } from 'query-string'
33
import MatchProvider from './MatchProvider'
4-
import { LocationEmitter } from './locationEmission'
4+
import { LocationBroadcast } from './locationBroadcast'
55
import {
66
locationsAreEqual,
77
createRouterLocation,
@@ -90,15 +90,15 @@ class StaticRouter extends React.Component {
9090
const { action, children } = this.props
9191

9292
return (
93-
<LocationEmitter value={location}>
93+
<LocationBroadcast value={location}>
9494
<MatchProvider>
9595
{typeof children === 'function' ? (
9696
children({ action, location, router: this.getRouterContext() })
9797
) : (
9898
React.Children.only(children)
9999
)}
100100
</MatchProvider>
101-
</LocationEmitter>
101+
</LocationBroadcast>
102102
)
103103
}
104104
}

modules/__tests__/Link-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import expect from 'expect'
22
import React, { PropTypes } from 'react'
33
import Link from '../Link'
44
import { render } from 'react-dom'
5-
import { LocationEmitter } from '../locationEmission'
5+
import { LocationBroadcast } from '../locationBroadcast'
66

77
describe('Link', () => {
88

@@ -258,12 +258,12 @@ describe('Link', () => {
258258
const div = document.createElement('div')
259259
const location = { pathname: PATHNAME, search: '', hash: '' }
260260
render((
261-
<LocationEmitter value={location}>
261+
<LocationBroadcast value={location}>
262262
<Link
263263
to={PATHNAME}
264264
activeClassName="active"
265265
/>
266-
</LocationEmitter>
266+
</LocationBroadcast>
267267
), div)
268268
const a = div.querySelector('a')
269269
expect(a.className).toEqual('active')

modules/__tests__/Match-test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react'
33
import Match from '../Match'
44
import { renderToString } from 'react-dom/server'
55
import { render } from 'react-dom'
6-
import { LocationEmitter } from '../locationEmission'
6+
import { LocationBroadcast } from '../locationBroadcast'
77

88
describe('Match', () => {
99
const TEXT = 'TEXT'
@@ -277,11 +277,11 @@ describe('Match', () => {
277277
const TEXT = 'TEXT'
278278
const location = { pathname: '/', state: { test: TEXT } }
279279
const html = renderToString(
280-
<LocationEmitter value={location}>
280+
<LocationBroadcast value={location}>
281281
<Match pattern="/" render={({ location }) => (
282282
<div>{location.state.test}</div>
283283
)}/>
284-
</LocationEmitter>
284+
</LocationBroadcast>
285285
)
286286
expect(html).toContain(TEXT)
287287
})
@@ -293,11 +293,11 @@ describe('Match', () => {
293293
const contextLoc = { pathname: '/', state: { test: CONTEXT } }
294294
const propsLoc = { pathname: '/', state: { test: PROP } }
295295
const html = renderToString(
296-
<LocationEmitter value={contextLoc}>
296+
<LocationBroadcast value={contextLoc}>
297297
<Match location={propsLoc} pattern="/" render={({ location }) => (
298298
<div>{location.state.test}</div>
299299
)}/>
300-
</LocationEmitter>
300+
</LocationBroadcast>
301301
)
302302
expect(html).toNotContain(CONTEXT)
303303
expect(html).toContain(PROP)

modules/locationBroadcast.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*eslint react/prop-types: 0*/
2+
import React from 'react'
3+
import { Broadcast, Subscriber } from 'react-broadcast'
4+
5+
const NAME = 'location'
6+
7+
const LocationBroadcast = ({ children, value }) =>
8+
<Broadcast channel={NAME} value={value} children={children}/>
9+
10+
const LocationSubscriber = ({ children }) =>
11+
<Subscriber channel={NAME} children={children}/>
12+
13+
export { LocationBroadcast, LocationSubscriber }

modules/locationEmission.js

-7
This file was deleted.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"dependencies": {
2929
"path-to-regexp": "^1.5.3",
3030
"query-string": "4.2.3",
31-
"react-context-emission": "^2.1.0",
31+
"react-broadcast": "^0.1.1",
3232
"react-history": "^0.14.0"
3333
},
3434
"peerDependencies": {

0 commit comments

Comments
 (0)