Skip to content

Commit

Permalink
feat: Deprecate options.cozyClient, use options.client
Browse files Browse the repository at this point in the history
Intents / Bar etc..  use options.client for the CozyClient, it will be
easier to have the plugin system if all classes depending on the client
use the same attribute.
  • Loading branch information
ptbrowne committed May 24, 2019
1 parent 949b99e commit ed3f8ad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions packages/cozy-realtime/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,21 @@ class CozyRealtime {
* - unsubscribeAll if window unload
*
* @constructor
* @param {CozyClient} cozyClient A cozy client
* @param {CozyClient} client A cozy client
* @param {CozyClient} cozyClient A cozy client [DEPRECATED]
*/
constructor({ cozyClient }) {
this._cozyClient = cozyClient
constructor({ cozyClient, client }) {
if (cozyClient) {
console.warn(
'Realtime: options.cozyClient is deprecated, please use options.client'
)
}
this._cozyClient = client || cozyClient
if (!this._cozyClient) {
throw new Error(
'Realtime must be initialized with a client. Ex: new Realtime({ client })'
)
}

this._updateAuthentication = this._updateAuthentication.bind(this)
this.unsubscribeAll = this.unsubscribeAll.bind(this)
Expand Down
2 changes: 1 addition & 1 deletion packages/cozy-realtime/src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('CozyRealtime', () => {
let realtime, cozyStack

beforeEach(() => {
realtime = new CozyRealtime({ cozyClient })
realtime = new CozyRealtime({ client: cozyClient })
cozyStack = new Server(WS_URL)
cozyStack.emitMessage = (type, doc, event, id) => {
cozyStack.emit(
Expand Down

0 comments on commit ed3f8ad

Please sign in to comment.