Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Pass options to ascoltatores #55

Merged
merged 4 commits into from May 22, 2013
Merged

Pass options to ascoltatores #55

merged 4 commits into from May 22, 2013

Conversation

davedoesdev
Copy link
Collaborator

Extra parameter is optional.
memory and mqtt ascoltatores updated.
Test for memory ascoltatores, mqtt test needs to be done after mosca is updated to take advantage of the options (e.g. to pass the qos through).

Issue #53

Extra parameter is optional.
memory and mqtt ascoltatores updated.
Test for memory ascoltatores, mqtt test needs to be done after mosca is updated to take advantage of the options (e.g. to pass the qos through).

Object.defineProperty(this, "publish", {
get: function() { return this._publish; },
set: this._set_publish
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you adding a public set for the publish function?
Is that needed somewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test fails without it (spy fails to set its publish intercept):

  1. ascoltatori should delegate to the use ascoltatore for 'pub':
    TypeError: Cannot set property publish of # which has only a getter
    at Object.wrapMethod (/home/david/Private/hub/node_modules/mosca/node_modules/ascoltatori/node_modules/sinon/lib/sinon.js:80:30)
    at Object.spy (/home/david/Private/hub/node_modules/mosca/node_modules/ascoltatori/node_modules/sinon/lib/sinon/spy.js:42:22)
    at Object.spy (/home/david/Private/hub/node_modules/mosca/node_modules/ascoltatori/node_modules/sinon/lib/sinon/collection.js:88:39)
    at Context. (/home/david/Private/hub/node_modules/mosca/node_modules/ascoltatori/test/ascoltatori_spec.js:26:28)
    at Test.Runnable.run (/usr/lib/node_modules/mocha/lib/runnable.js:213:32)
    at Runner.runTest (/usr/lib/node_modules/mocha/lib/runner.js:351:10)
    at Runner.runTests.next (/usr/lib/node_modules/mocha/lib/runner.js:397:12)
    at next (/usr/lib/node_modules/mocha/lib/runner.js:277:14)
    at Runner.hooks (/usr/lib/node_modules/mocha/lib/runner.js:286:7)
    at next (/usr/lib/node_modules/mocha/lib/runner.js:234:23)
    at Runner.hook (/usr/lib/node_modules/mocha/lib/runner.js:249:7)
    at Hook.Runnable.run (/usr/lib/node_modules/mocha/lib/runnable.js:215:5)
    at next (/usr/lib/node_modules/mocha/lib/runner.js:243:10)
    at Runner.hook (/usr/lib/node_modules/mocha/lib/runner.js:254:5)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, but having a real ascoltatore is not really needed in that test.
Could you please fix the ascoltatori_spec.js not to override that, and maybe use a fake one all the way?
Is it the only problem?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends whether you want people to be able to set the publish method in the constructor (this.publish = ...) as an alternative to using the prototype.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually not, the supported way is using the prototype.
Do you see any actual use case for this?

@davedoesdev
Copy link
Collaborator Author

I removed the getters, only using the prototype now and added fake ascoltatore for the test

It was causing a double 'ready' event emission.
Instead, make the functions to set up publish and subscribe methods available
to deriving classes and call them in DecoratorAscoltatore.
@davedoesdev
Copy link
Collaborator Author

Fixed double ready emits by reverting to not inheriting from DecoratorAscoltatore from AbstractAscoltatore.
It was complicating what was getting fired at which time.

mcollina added a commit that referenced this pull request May 22, 2013
Pass options to each Ascoltatore#publish and #subscribe
@mcollina mcollina merged commit 6a5a349 into moscajs:master May 22, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants