diff --git a/src/mixin.js b/src/mixin.js index e8282c4..413ba16 100644 --- a/src/mixin.js +++ b/src/mixin.js @@ -46,7 +46,7 @@ export default { } vm._obSubscriptions.push(obs[key].subscribe(value => { vm[key] = value - })) + }, (error) => { throw error })) }) } }, diff --git a/test/test.js b/test/test.js index b71ec08..1768472 100644 --- a/test/test.js +++ b/test/test.js @@ -117,6 +117,29 @@ test('subscriptions() has access to component state', () => { expect(vm.$el.textContent).toBe('FOOBAR') }) +test('subscriptions() can throw error properly', done => { + const { ob, next } = mock() + + const vm = new Vue({ + subscriptions () { + return { + num: ob.startWith(1).map(n => n.toFixed()) + } + }, + render (h) { + return h('div', this.num) + } + }).$mount() + + nextTick(() => { + expect(() => { + next(null) + }).toThrow() + expect(vm.$el.textContent).toBe('1') + done() + }) +}) + test('v-stream directive (basic)', done => { const vm = new Vue({ template: `