1- /*eslint-env mocha*/
21/*eslint react/prop-types: 0*/
32import React from 'react'
43import { render } from 'react-dom'
5- import expect from 'expect'
64import { EventEmitter } from 'events'
7- import { Subscriber , Broadcast } from '../index'
5+ import { Broadcast , Subscriber } from '../index'
86
97it ( 'works' , ( done ) => {
10-
118 const steps = [ ]
129 const execNextStep = ( ) => steps . shift ( ) ( )
1310 const div = document . createElement ( 'div' )
@@ -16,11 +13,12 @@ it('works', (done) => {
1613 const emitter = new EventEmitter ( )
1714
1815 // A component has some state it wants to make available to descendants
19- // 1. We create our Emitter and Subscriber components
20- const CheeseEmitter = ( { cheese, children } ) =>
16+ // 1. We create our Broadcast and Subscriber components
17+ const CheeseBroadcast = ( { cheese, children } ) =>
2118 < Broadcast channel = "cheese" value = { cheese } children = { children } />
19+
2220 const CheeseSubscriber = ( { children } ) =>
23- < Subscriber channel = "cheese" > { ( value ) => children ( value ) } </ Subscriber >
21+ < Subscriber channel = "cheese" children = { children } / >
2422
2523 class ComponentWithStateForDescendants extends React . Component {
2624 constructor ( ) {
@@ -36,13 +34,13 @@ it('works', (done) => {
3634 componentDidUpdate = execNextStep
3735
3836 render ( ) {
39- // 2. render the Emitter in the component w/ state and pass
37+ // 2. render the Broadcast in the component w/ state and pass
4038 // it the value we want accessible through context as a prop
41- // by the same name as when the Emitter was created
39+ // by the same name as when the Broadcast was created
4240 return (
43- < CheeseEmitter cheese = { this . state . cheese } >
41+ < CheeseBroadcast cheese = { this . state . cheese } >
4442 { this . props . children }
45- </ CheeseEmitter >
43+ </ CheeseBroadcast >
4644 )
4745 }
4846 }
@@ -60,7 +58,7 @@ it('works', (done) => {
6058 }
6159 )
6260
63- // 3. Render a <Subscriber> that calls back when the Emitter
61+ // 3. Render a <Subscriber> that calls back when the Broadcast
6462 // gets a new value in its prop
6563 render ( (
6664 < ComponentWithStateForDescendants >
@@ -73,4 +71,3 @@ it('works', (done) => {
7371 </ ComponentWithStateForDescendants >
7472 ) , div )
7573} )
76-
0 commit comments