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

Commit

Permalink
Browse files Browse the repository at this point in the history
working
  • Loading branch information
tgoc99 committed Aug 23, 2018
1 parent 8c60cb2 commit a0df737
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion html/service.html
Expand Up @@ -10,7 +10,7 @@ <h3>Service Provider</h3>

<script>
fin.desktop.main(async () => {
const provider = await fin.InterApplicationBus.Channel.create('mrtest');
const provider = await fin.InterApplicationBus.Channel.create('test');
provider.register('test', (payload, id) => {
provider.dispatch(id, 'multi-runtime-test', 'return-mrt');
return 'return-test';
Expand Down
8 changes: 4 additions & 4 deletions src/api/base.ts
Expand Up @@ -90,10 +90,10 @@ export class EmitterBase extends Base {
const newRefCount = refCount - 1;
if (newRefCount === 0) {
await this.wire.sendAction('unsubscribe-to-desktop-event', runtimeEvent);
if (emitter.eventNames().length === 0) {
this.wire.eventAggregator.delete(this.emitterAccessor);
return;
}
// if (Object.keys(this.getEmitter()._events).length === 0) {
// this.wire.eventAggregator.delete(this.emitterAccessor);
// return;
// }
}
return emitter;
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/interappbus/channel/index.ts
Expand Up @@ -78,7 +78,7 @@ export class Channel extends EmitterBase {
} catch (e) {
const shouldWait: boolean = Object.assign({ wait: true }, opts).wait;
const internalNackMessage = 'internal-nack';
if (shouldWait && e.message === internalNackMessage) {
if (shouldWait && e.message.includes(internalNackMessage)) {
console.warn(`Channel not found for channelName: ${channelName}, waiting for channel creation.`);
return await waitResponse;
} else if (e.message === internalNackMessage) {
Expand Down
6 changes: 3 additions & 3 deletions test/multi-runtime-channel.test.ts
Expand Up @@ -46,7 +46,7 @@ describe ('Multi Runtime Channels', function() {
async function test () {
const spy = sinon.spy();
const [finA, finB] = await Promise.all([launchAndConnect(), launchAndConnect()]);
const provider = await finB.InterApplicationBus.Channel.create('test');
const provider = await finB.InterApplicationBus.Channel.create('test-ext-provider');
provider.register('test', () => {
spy();
return 'return-test';
Expand All @@ -62,7 +62,7 @@ describe ('Multi Runtime Channels', function() {
assert.equal(msg, 'return-test');
done();
});
await finB.InterApplicationBus.publish('start', 'hi');
await finB.InterApplicationBus.publish('start', 'test-ext-provider');
}
test().catch(() => cleanOpenRuntimes());
});
Expand Down Expand Up @@ -156,7 +156,7 @@ describe ('Multi Runtime Channels', function() {

async function test() {
const [finA, finB] = await Promise.all([launchAndConnect(), launchAndConnect()]);
finB.InterApplicationBus.Channel.connect('mrtest')
finB.InterApplicationBus.Channel.connect('test')
.then((c) => {
c.register('multi-runtime-test', (r: string) => {
assert.equal(r, 'return-mrt', 'wrong payload sent from service');
Expand Down

0 comments on commit a0df737

Please sign in to comment.