Skip to content
Browse files

Implement port default values, fixes #149

  • Loading branch information...
1 parent 4f1c034 commit a8de0e2ba29ce2a10a33a2461de5ec9656d78704 @bergie bergie committed Mar 2, 2014
Showing with 11 additions and 1 deletion.
  1. +3 −1 spec/InPort.coffee
  2. +8 −0 src/lib/InPort.coffee
View
4 spec/InPort.coffee
@@ -67,7 +67,9 @@ describe 'Inport Port', ->
p.on 'data', (data) ->
chai.expect(data).to.equal received.shift()
done() if received.length is 0
- s.send 'some-iip'
+ setTimeout ->
+ s.send 'some-iip'
+ , 0
describe 'with options stored in port', ->
it 'should store all provided options in port, whether we expect it or not', ->
View
8 src/lib/InPort.coffee
@@ -23,6 +23,8 @@ class InPort extends BasePort
super options
+ do @sendDefault
+
attachSocket: (socket, localId = null) ->
socket.on 'connect', =>
@handleSocketEvent 'connect', socket, localId
@@ -47,4 +49,10 @@ class InPort extends BasePort
return @emit event, payload, id if @isAddressable()
@emit event, payload
+ sendDefault: ->
+ return if @options.default is undefined
+ setTimeout =>
+ @emit 'data', @options.default
+ , 0
+
module.exports = InPort

0 comments on commit a8de0e2

Please sign in to comment.
Something went wrong with that request. Please try again.