Skip to content

Commit 3949d91

Browse files
Update docs about naming convention when 2+ callbacks
1 parent e88a90e commit 3949d91

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Node/EventEmitter.purs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,17 @@ foreign import unsafeEmitFn :: forall f. EventEmitter -> f Boolean
155155
-- | Packs all the type information we need to call `on`/`once`/`prependListener`/`prependOnceListener`
156156
-- | with the correct callback function type.
157157
-- |
158-
-- | **Naming convention**: If the name of an event is `foo`,
158+
-- | **Naming convention**:
159+
-- | If the name of an event is `foo`,
159160
-- | the corresponding PureScript `EventHandle` value should be called `fooH`.
160161
-- | The `H` suffix is what prevent name conflicts in two situations:
161162
-- | 1. similarly-named methods (e.g. the `"close"` event and the `close` method)
162163
-- | 2. PureScript keywords (e.g. the `"data"` event)
164+
-- |
165+
-- | If an event, `foo`, can have two different kinds of callbacks, (e.g. See `Node.Stream`'s `data` event),
166+
-- | one of two things should happen:
167+
-- | 1. a suffix should follow the `H` to distinguish between the two (e.g. `dataHString`/`dataHBuffer`)
168+
-- | 2. a prime character (i.e. `'`) should follow the `H` to distinguish between the two (e.g. `dataH`/`dataH'`)
163169
data EventHandle :: Type -> Type -> Type -> Type
164170
data EventHandle emitterType pureScriptCallback javaScriptCallback =
165171
EventHandle String (pureScriptCallback -> javaScriptCallback)

0 commit comments

Comments
 (0)