docs(docs-infra): temporary removal of core/rxjs-interop dependency (#60234)

To work around the limitation of #54858, this commit removes temporarly the dependency to `core/rxjs-interop` to allow the removal of the microtask effect which was pulled by that entry.

This commit is intented to be reverted once the next patch/next is released.

PR Close #60234
This commit is contained in:
Matthieu Riegler
2025-03-06 13:29:19 +01:00
committed by Andrew Kushnir
parent 02cb7e061a
commit fa712aede5
6 changed files with 107 additions and 6 deletions
@@ -30,12 +30,12 @@ import {TextField} from '../text-field/text-field.component';
import {FormsModule} from '@angular/forms';
import {ActiveDescendantKeyManager} from '@angular/cdk/a11y';
import {SearchItem} from '../../directives/search-item/search-item.directive';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {Router, RouterLink} from '@angular/router';
import {filter, fromEvent} from 'rxjs';
import {fromEvent} from 'rxjs';
import {AlgoliaIcon} from '../algolia-icon/algolia-icon.component';
import {RelativeLink} from '../../pipes/relative-link.pipe';
import {SearchResult, SnippetResult} from '../../interfaces';
import {takeUntilDestroyed} from '../../services/rxjs-interop';
@Component({
selector: 'docs-search-dialog',
@@ -28,7 +28,6 @@ import {
ɵPendingTasksInternal as PendingTasks,
output,
} from '@angular/core';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {TOC_SKIP_CONTENT_MARKER, NavigationState} from '../../../services/index';
import {TableOfContents} from '../../table-of-contents/table-of-contents.component';
import {IconComponent} from '../../icon/icon.component';
@@ -40,6 +39,7 @@ import {fromEvent} from 'rxjs';
import {Breadcrumb} from '../../breadcrumb/breadcrumb.component';
import {CopySourceCodeButton} from '../../copy-source-code-button/copy-source-code-button.component';
import {ExampleViewer} from '../example-viewer/example-viewer.component';
import {takeUntilDestroyed} from '../../../services/rxjs-interop';
/// <reference types="@types/dom-view-transitions" />
@@ -29,8 +29,8 @@ import {Clipboard} from '@angular/cdk/clipboard';
import {CopySourceCodeButton} from '../../copy-source-code-button/copy-source-code-button.component';
import {ExampleMetadata, Snippet} from '../../../interfaces/index';
import {EXAMPLE_VIEWER_CONTENT_LOADER} from '../../../providers/index';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {DocViewer} from '../docs-viewer/docs-viewer.component';
import {takeUntilDestroyed} from '../../../services/rxjs-interop';
export enum CodeExampleViewMode {
SNIPPET = 'snippet',
-1
View File
@@ -30,7 +30,6 @@ ng_module(
"//adev/shared-docs/utils",
"//packages/common",
"//packages/core",
"//packages/core/rxjs-interop",
"//packages/router",
"@npm//algoliasearch",
"@npm//rxjs",
+102
View File
@@ -0,0 +1,102 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {
assertInInjectionContext,
DestroyRef,
effect,
inject,
Injector,
Signal,
untracked,
} from '@angular/core';
import {Observable, ReplaySubject, MonoTypeOperatorFunction, takeUntil} from 'rxjs';
// *******************************
// TODO: Remove the file and revert the commit it belonged to in https://github.com/angular/angular/pull/60234
// Once the next version of core package has been released
// *******************************
/**
* Operator which completes the Observable when the calling context (component, directive, service,
* etc) is destroyed.
*
* @param destroyRef optionally, the `DestroyRef` representing the current context. This can be
* passed explicitly to use `takeUntilDestroyed` outside of an [injection
* context](guide/di/dependency-injection-context). Otherwise, the current `DestroyRef` is injected.
*
* @publicApi
*/
export function takeUntilDestroyed<T>(destroyRef?: DestroyRef): MonoTypeOperatorFunction<T> {
if (!destroyRef) {
assertInInjectionContext(takeUntilDestroyed);
destroyRef = inject(DestroyRef);
}
const destroyed$ = new Observable<void>((observer) => {
const unregisterFn = destroyRef!.onDestroy(observer.next.bind(observer));
return unregisterFn;
});
return <T>(source: Observable<T>) => {
return source.pipe(takeUntil(destroyed$));
};
}
/**
* Options for `toObservable`.
*
* @developerPreview
*/
export interface ToObservableOptions {
/**
* The `Injector` to use when creating the underlying `effect` which watches the signal.
*
* If this isn't specified, the current [injection context](guide/di/dependency-injection-context)
* will be used.
*/
injector?: Injector;
}
/**
* Exposes the value of an Angular `Signal` as an RxJS `Observable`.
*
* The signal's value will be propagated into the `Observable`'s subscribers using an `effect`.
*
* `toObservable` must be called in an injection context unless an injector is provided via options.
*
* @developerPreview
*/
export function toObservable<T>(source: Signal<T>, options?: ToObservableOptions): Observable<T> {
!options?.injector && assertInInjectionContext(toObservable);
const injector = options?.injector ?? inject(Injector);
const subject = new ReplaySubject<T>(1);
const watcher = effect(
() => {
let value: T;
try {
value = source();
} catch (err) {
untracked(() => subject.error(err));
return;
}
untracked(() => subject.next(value));
},
{injector, manualCleanup: true},
);
injector.get(DestroyRef).onDestroy(() => {
watcher.destroy();
subject.complete();
});
return subject.asObservable();
}
+1 -1
View File
@@ -9,10 +9,10 @@
import {Injectable, afterNextRender, inject, signal} from '@angular/core';
import {ENVIRONMENT} from '../providers/index';
import {SearchResult} from '../interfaces/index';
import {toObservable} from '@angular/core/rxjs-interop';
import {debounceTime, filter, from, of, switchMap} from 'rxjs';
import {liteClient as algoliasearch} from 'algoliasearch/lite';
import {NavigationEnd, Router} from '@angular/router';
import {toObservable} from './rxjs-interop';
export const SEARCH_DELAY = 200;
// Maximum number of facet values to return for each facet during a regular search.