Skip to content

Commit

Permalink
fix: Expose sendNotification from cozy-client realtime plugin
Browse files Browse the repository at this point in the history
It is especially needed in harvest to send notification from harvest
to the banks application to know when a job is waited for.

And since the realtime plugin is supposed to expose the same api as
CozyRealtime
  • Loading branch information
doubleface authored and doubleface committed Oct 3, 2022
1 parent 8b93988 commit 82500b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/cozy-realtime/src/RealtimePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ class RealtimePlugin {
this.checkRealtimeInstance()
this.realtime.unsubscribeAll()
}

/**
* @see CozyRealtime.sendNotification
*/
sendNotification(...args) {
this.checkRealtimeInstance()
this.realtime.sendNotification(...args)
}
}

RealtimePlugin.pluginName = 'realtime'
Expand Down
1 change: 1 addition & 0 deletions packages/cozy-realtime/src/RealtimePlugin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ it('should expose the same API as CozyRealtime', () => {
expect(client.plugins.realtime.subscribe).toBeInstanceOf(Function)
expect(client.plugins.realtime.unsubscribe).toBeInstanceOf(Function)
expect(client.plugins.realtime.unsubscribeAll).toBeInstanceOf(Function)
expect(client.plugins.realtime.sendNotification).toBeInstanceOf(Function)
})

it('should login/logout correctly', async () => {
Expand Down

0 comments on commit 82500b4

Please sign in to comment.