SF-3532 Dispose realtime docs when no longer in use#3199
Conversation
abf739b to
db6ad5d
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3199 +/- ##
==========================================
- Coverage 81.03% 81.02% -0.02%
==========================================
Files 645 646 +1
Lines 41523 41741 +218
Branches 6758 6787 +29
==========================================
+ Hits 33650 33819 +169
- Misses 6761 6807 +46
- Partials 1112 1115 +3 ☔ View full report in Codecov by Harness. |
9fcd8f8 to
74cce2c
Compare
e689f5d to
9d7185b
Compare
e689f5d to
7842d29
Compare
7842d29 to
b990402
Compare
5a61ab3 to
89e0fd9
Compare
89e0fd9 to
d59fd6c
Compare
|
Hello @Nateowami , Thank you for your work on this! Here are some comments on the code. I find positive names to be easier to understand than negative names, when using boolean logic. I suggest to consider renaming Can you explain more about the use of Rather than provide DocSubscription.unsubscribe for situations where a DestroyRef|Observable was not provided to DocSubscription.constructor, do you think we could always require clients to do one of
It looks like if we removed DocSubscription.unsubscribe, and instead had clients pass an Observable, that might look something like // New client field
private readonly bye$ = new Subject<void>();
...
// Pass in constructor
new DocSubscription('DraftGenerationStepsComponent', this.bye$.asObservable())
...
// New client method
wave(): void {
this.bye$.next();
this.bye$.complete();
}I want to mention that we could further reduce the complexity of DocSubscription by changing the constructor destroyRef argument from new DocSubscription('DraftGenerationStepsComponent', this.destroyRef)to something like new DocSubscription('DraftGenerationStepsComponent', new Observable(subscriber => this.destroyRef.onDestroy(() => subscriber.next())))That makes the client code more complex just to simplify DocSubscription.constructor by a couple lines, so I'm not too inclined toward it. But I wanted to mention that idea in case it inspires other ideas. Sometimes when working in TypeScript it seems like it could be useful to have a standard disposable system. In C#, there is an IDisposable interface, and implementing classes have a
In C#, the IDisposal.dispose method is automatically called if you are |
2a921bc to
52e5564
Compare
… project to My projects page
Loading questions appears to be tied to the lifetime of the requesting component, which may be giving a performance penalty when navigating around the application. (I did a lot of timing experiments, and didn't yet find it as clear cut as one might have hoped.) This patch gives more flexibility for query subscription lifecycle management by letting callers pass essentially a DocSubscription (but called a QuerySubscription) when creating a query. Then the query can stay around longer, such as until switching to another project. Since we already have subscription and resource management in queries, this may not work out entirely as intended so far, but this patch is at least a step.
2b25245 to
b1583b8
Compare
This is still work in progress, but I want to put it out here as it appears to be working.
This change is