Skip to content

Commit

Permalink
some methods marked private in channel are not private in practice
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerbarker committed May 12, 2024
1 parent 035b56c commit f8ae70f
Showing 1 changed file with 24 additions and 33 deletions.
57 changes: 24 additions & 33 deletions phoenix/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,30 @@ export default class Channel {
return payload;
}

joinRef() {
return this.joinPush.ref;
}

trigger(event, payload, ref, joinRef) {
let handledPayload = this.onMessage(event, payload, ref, joinRef);
if (payload && !handledPayload) {
throw new Error(
"channel onMessage callbacks must return the payload, modified or unmodified",
);
}

let eventBindings = this.bindings.filter((bind) => bind.event === event);

for (let i = 0; i < eventBindings.length; i++) {
let bind = eventBindings[i];
bind.callback(handledPayload, ref, joinRef || this.joinRef());
}
}

replyEventName(ref) {
return `chan_reply_${ref}`;
}

/**
* @private
*/
Expand All @@ -308,13 +332,6 @@ export default class Channel {
}
}

/**
* @private
*/
joinRef() {
return this.joinPush.ref;
}

/**
* @private
*/
Expand All @@ -327,32 +344,6 @@ export default class Channel {
this.joinPush.resend(timeout);
}

/**
* @private
*/
trigger(event, payload, ref, joinRef) {
let handledPayload = this.onMessage(event, payload, ref, joinRef);
if (payload && !handledPayload) {
throw new Error(
"channel onMessage callbacks must return the payload, modified or unmodified",
);
}

let eventBindings = this.bindings.filter((bind) => bind.event === event);

for (let i = 0; i < eventBindings.length; i++) {
let bind = eventBindings[i];
bind.callback(handledPayload, ref, joinRef || this.joinRef());
}
}

/**
* @private
*/
replyEventName(ref) {
return `chan_reply_${ref}`;
}

/**
* @private
*/
Expand Down

0 comments on commit f8ae70f

Please sign in to comment.