Skip to content

Commit

Permalink
Add rxjs/recommend eslint rules (#2724)
Browse files Browse the repository at this point in the history
We will probably want to tweak these as we get more used to them.
  • Loading branch information
hughns authored Nov 6, 2024
1 parent c45f724 commit 7fd3443
Show file tree
Hide file tree
Showing 5 changed files with 290 additions and 32 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ Please see LICENSE in the repository root for full details.
`;

module.exports = {
plugins: ["matrix-org"],
plugins: ["matrix-org", "rxjs"],
extends: [
"plugin:matrix-org/react",
"plugin:matrix-org/a11y",
"plugin:matrix-org/typescript",
"prettier",
"plugin:rxjs/recommended",
],
parserOptions: {
ecmaVersion: "latest",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"eslint-plugin-matrix-org": "^1.2.1",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-rxjs": "^5.0.3",
"eslint-plugin-unicorn": "^56.0.0",
"global-jsdom": "^25.0.0",
"history": "^4.0.0",
Expand Down
5 changes: 4 additions & 1 deletion src/state/MediaViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,10 @@ abstract class BaseMediaViewModel extends ViewModel {
encryptionSystem.kind !== E2eeType.NONE &&
(a.publication?.isEncrypted === false ||
v.publication?.isEncrypted === false),
).pipe(distinctUntilChanged(), shareReplay(1));
).pipe(
distinctUntilChanged(),
shareReplay({ bufferSize: 1, refCount: false }),
);

if (participant.isLocal || encryptionSystem.kind === E2eeType.NONE) {
this.encryptionStatus = of(EncryptionStatus.Okay).pipe(
Expand Down
6 changes: 5 additions & 1 deletion src/state/ObservableScope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export class ObservableScope {
}

private readonly stateImpl: MonoTypeOperator = (o) =>
o.pipe(this.bind(), distinctUntilChanged(), shareReplay(1));
o.pipe(
this.bind(),
distinctUntilChanged(),
shareReplay({ bufferSize: 1, refCount: false }),
);

/**
* Transforms an Observable into a hot state Observable which replays its
Expand Down
Loading

0 comments on commit 7fd3443

Please sign in to comment.