Document what all of our "Pegs" are (just singletons) (#8510)
As discussed at https://matrix.to/#/!fLeHeojWgBGJlLNdLC:matrix.org/$DHCPeZQ1aty_1l_nNHo_5F8Uwb3t29N1zuabWa5qLzM?via=matrix.org&via=element.io&via=vector.modular.im Peg is used in the literal sense: > a short pin or bolt, typically tapered at one end, that is used for securing something in place, hanging things on, or marking a position. Looking for an `MatrixClient`? Just look for the `MatrixClientPeg` on the peg board. So you'll find a `MatrixClient` hanging on the `MatrixClientPeg`. Maybe you're more familiar with these alternative names like `MatrixClientSingleton` but that's a bit long and Java-y or `MatrixClientHandle` in the win32 world.
This commit is contained in:
parent
3a241e0dfb
commit
8add540f27
3 changed files with 25 additions and 5 deletions
|
@ -49,6 +49,12 @@ export interface IMatrixClientCreds {
|
|||
freshLogin?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds the current instance of the `MatrixClient` to use across the codebase.
|
||||
* Looking for an `MatrixClient`? Just look for the `MatrixClientPeg` on the peg
|
||||
* board. "Peg" is the literal meaning of something you hang something on. So
|
||||
* you'll find a `MatrixClient` hanging on the `MatrixClientPeg`.
|
||||
*/
|
||||
export interface IMatrixClientPeg {
|
||||
opts: IStartClientOpts;
|
||||
|
||||
|
@ -311,6 +317,10 @@ class MatrixClientPegClass implements IMatrixClientPeg {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: You should be using a React context with access to a client rather than
|
||||
* using this, as in a multi-account world this will not exist!
|
||||
*/
|
||||
export const MatrixClientPeg: IMatrixClientPeg = new MatrixClientPegClass();
|
||||
|
||||
if (!window.mxMatrixClientPeg) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue