repo_name stringlengths 1 62 | dataset stringclasses 1
value | lang stringclasses 11
values | pr_id int64 1 20.1k | owner stringlengths 2 34 | reviewer stringlengths 2 39 | diff_hunk stringlengths 15 262k | code_review_comment stringlengths 1 99.6k |
|---|---|---|---|---|---|---|---|
ngxtension-platform | github_2023 | typescript | 404 | ngxtension | ajitzero | @@ -0,0 +1,27 @@
+import { concatMap, MonoTypeOperatorFunction, Observable, timer } from 'rxjs';
+// source: https://netbasal.com/use-rxjs-to-modify-app-behavior-based-on-page-visibility-ce499c522be4
+
+/**
+ * RxJS operator to apply to a stream that you want to poll every "period" milliseconds after an optional "initi... | nit: formatting
```suggestion
concatMap(() => source),
``` |
ngxtension-platform | github_2023 | typescript | 408 | ngxtension | nartc | @@ -6,30 +6,40 @@ import {
} from '@angular/core';
import {
toObservable,
+ toSignal,
type ToObservableOptions,
} from '@angular/core/rxjs-interop';
-import type { Observable } from 'rxjs';
+import type { Observable, Subscribable } from 'rxjs';
export type ObservableSignal<T> = Signal<T> & Observable<T>;
e... | nit: I think `Subscribable` already includes `Observable` so we shouldn't need both in the union here. |
ngxtension-platform | github_2023 | typescript | 408 | ngxtension | nartc | @@ -6,30 +6,40 @@ import {
} from '@angular/core';
import {
toObservable,
+ toSignal,
type ToObservableOptions,
} from '@angular/core/rxjs-interop';
-import type { Observable } from 'rxjs';
+import type { Observable, Subscribable } from 'rxjs';
export type ObservableSignal<T> = Signal<T> & Observable<T>;
e... | suggestion: can we use `isSignal()` instead? This will probably remove the need of `as Signal<T>` down below |
ngxtension-platform | github_2023 | typescript | 382 | ngxtension | nartc | @@ -221,10 +223,24 @@ export async function convertDiToInjectGenerator(
}
});
} else {
+ const hasPrivateScope = scope == Scope.Private; | nit: please use `===` |
ngxtension-platform | github_2023 | typescript | 382 | ngxtension | nartc | @@ -221,10 +223,24 @@ export async function convertDiToInjectGenerator(
}
});
} else {
+ const hasPrivateScope = scope == Scope.Private;
+ const propertyName =
+ hasPrivateScope && options.useESPrivateFieldNotation
+ ? `#${name}`
+ : name;
+
+ if (hasPrivateScope)... | nit: this can be simplified as `hasPrivateScope && options.useESPrivateFieldNotation ? null : scope` |
ngxtension-platform | github_2023 | others | 393 | ngxtension | nartc | @@ -0,0 +1,3 @@
+# ngxtension/create-effect
+
+Secondary entry point of `ngxtension`. It can be used by importing from `ngxtension/create-effect`. | ```suggestion
# ngxtension/explicit-effect
Secondary entry point of `ngxtension`. It can be used by importing from `ngxtension/explicit-effect`.
``` |
ngxtension-platform | github_2023 | typescript | 378 | ngxtension | eneajaho | @@ -221,10 +221,14 @@ export async function convertDiToInjectGenerator(
}
});
} else {
+ const propertyName = options.useESPrivateFieldNotation
+ ? `#${name}`
+ : name;
+
targetClass.insertProperty(index, {
- name,
+ name: propertyName,
initializer,
- ... | If the field is protected I don't think we should convert it to private. So I'd only convert private properties to use the # and keep the others as is. |
ngxtension-platform | github_2023 | others | 356 | ngxtension | eneajaho | @@ -0,0 +1,119 @@
+---
+title: Queries Migration
+description: Schematics for migrating from decorator-based Queries to Signal-based Queries
+entryPoint: convert-queries
+badge: stable
+contributors: ['enea-jahollari']
+---
+
+To have a unifying experience with Signals, Angular 17 introduces the Signal-based Queries to... | ```suggestion
@ContentChildren('my-content-children') myContentChildren: QueryList<ElementRef<HTMLImageElement>>;
``` |
ngxtension-platform | github_2023 | others | 356 | ngxtension | eneajaho | @@ -0,0 +1,119 @@
+---
+title: Queries Migration
+description: Schematics for migrating from decorator-based Queries to Signal-based Queries
+entryPoint: convert-queries
+badge: stable
+contributors: ['enea-jahollari']
+---
+
+To have a unifying experience with Signals, Angular 17 introduces the Signal-based Queries to... | ```suggestion
@ViewChildren('my-view-children') myViewChildren: QueryList<ElementRef<HTMLImageElement>>;
``` |
ngxtension-platform | github_2023 | typescript | 319 | ngxtension | eneajaho | @@ -50,13 +48,11 @@ export class ClickOutside implements OnInit {
ngOnInit() {
this.documentClick$
.pipe(
- takeUntil(this.destroy$), | How does removing takeUntil remove a memory leak?
I don't understand this tbh.
We want to stop listening to documentClick on directive destroy, the injectDocumentClick is registered in root scope, so that won't ever be unsubscribed afaik. |
ngxtension-platform | github_2023 | typescript | 319 | ngxtension | eneajaho | @@ -34,14 +37,16 @@ const [injectDocumentClick] = createInjectionToken(() => {
* <div (clickOutside)="close()"></div>
*
*/
-@Directive({ selector: '[clickOutside]', standalone: true })
+@Directive({
+ selector: '[clickOutside]',
+ standalone: true,
+ providers: [provideDocumentClick()], | This will create a listener for each directive, while the previous method, would create only one listener for the whole document, and each directive will use the same listener, which makes it more performant I think. |
ngxtension-platform | github_2023 | typescript | 295 | ngxtension | eneajaho | @@ -0,0 +1,69 @@
+import { effect, signal, type WritableSignal } from '@angular/core';
+
+export type LocalStorageOptions<T> = {
+ defaultValue?: T | (() => T); | Can we add some comments for each option here?
It would make it easier when passing these options and to read some kind of comments on what they do and how they modify the way this function works. |
ngxtension-platform | github_2023 | typescript | 295 | ngxtension | eneajaho | @@ -0,0 +1,69 @@
+import { effect, signal, type WritableSignal } from '@angular/core';
+
+export type LocalStorageOptions<T> = {
+ defaultValue?: T | (() => T);
+ storageSync?: boolean;
+ stringify?: (value: unknown) => string;
+ parse?: (value: string) => unknown;
+};
+
+function isFunction(value: unknown): value is (... | Calling localStorage directly will fail in SSR environment, so having an injection token for this would make it better.
In SSR env we can do:
provideLocalStorageImpl();
and this fn can just add some mocked local storage impl for server or use some other kind of storage.
```ts
export const NGXTENSION_LOCA... |
ngxtension-platform | github_2023 | typescript | 295 | ngxtension | nartc | @@ -0,0 +1,113 @@
+import {
+ effect,
+ inject,
+ InjectionToken,
+ signal,
+ type WritableSignal,
+} from '@angular/core';
+
+export const NGXTENSION_LOCAL_STORAGE = new InjectionToken(
+ 'NGXTENSION_LOCAL_STORAGE',
+ {
+ providedIn: 'root',
+ factory: () => localStorage, // this would be the default
+ },
+);
+
+exp... | nit: please use `assertInjector()` to ensure this function is being called in an Injection Context. Also, can we go with top-level `function` declaration instead of Arrow Fn expression? |
ngxtension-platform | github_2023 | typescript | 326 | ngxtension | scr2em | @@ -0,0 +1,244 @@
+import {
+ Tree,
+ formatFiles,
+ getProjects,
+ logger,
+ readJson,
+ readProjectConfiguration,
+ visitNotIgnoredFiles,
+} from '@nx/devkit';
+import { readFileSync } from 'node:fs';
+import { exit } from 'node:process';
+import { Node, Project } from 'ts-morph';
+import { ConvertDiToInjectGenerator... | @eneajaho I think you should check if the constructor has `super()` only, if that's the case the constructor should be removed as well
```
constructor.getBodyText().trim() === 'super()'
``` |
ngxtension-platform | github_2023 | typescript | 232 | ngxtension | ajitzero | @@ -1,12 +1,25 @@
-import { Component } from '@angular/core';
+import { Component, numberAttribute } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { provideRouter } from '@angular/router';
import { RouterTestingHarness } from '@angular/router/testing';
-import { injectQueryParams } ... | Minor: I think following the `inject` prefix for CIFs is more intentional/consistent. |
ngxtension-platform | github_2023 | typescript | 232 | ngxtension | ajitzero | @@ -22,22 +35,96 @@ describe(injectQueryParams.name, () => {
expect(instance.queryParams()).toEqual({ query: 'Angular' });
expect(instance.searchParam()).toEqual('Angular');
+ expect(instance.idParam()).toEqual(null);
expect(instance.paramKeysList()).toEqual(['query']);
await harness.navigateByUrl('/se... | Question: Is `queryParams.multiple` a simpler variant of `injectQueryParams((params) => Object.keys(params))`? |
ngxtension-platform | github_2023 | typescript | 232 | ngxtension | JeanMeche | @@ -3,55 +3,269 @@ import { toSignal } from '@angular/core/rxjs-interop';
import { ActivatedRoute, type Params } from '@angular/router';
import { map } from 'rxjs';
+type QueryParamsTransformFn<ReadT> = (params: Params) => ReadT;
+
/**
- * Injects the query params from the current route.
+ * The `InputOptions` int... | This parameter could be removed right ? |
ngxtension-platform | github_2023 | typescript | 232 | ngxtension | JeanMeche | @@ -3,55 +3,269 @@ import { toSignal } from '@angular/core/rxjs-interop';
import { ActivatedRoute, type Params } from '@angular/router';
import { map } from 'rxjs';
+type QueryParamsTransformFn<ReadT> = (params: Params) => ReadT;
+
/**
- * Injects the query params from the current route.
+ * The `InputOptions` int... | ```suggestion
options: QueryParamsOptions<ReadT, string, ReadT> = {},
```
It would remove the condition a few lines below. |
ngxtension-platform | github_2023 | typescript | 232 | ngxtension | JeanMeche | @@ -3,55 +3,269 @@ import { toSignal } from '@angular/core/rxjs-interop';
import { ActivatedRoute, type Params } from '@angular/router';
import { map } from 'rxjs';
+type QueryParamsTransformFn<ReadT> = (params: Params) => ReadT;
+
/**
- * Injects the query params from the current route.
+ * The `InputOptions` int... | ```suggestion
```
nit: this could be removed |
ngxtension-platform | github_2023 | others | 232 | ngxtension | eneajaho | @@ -67,3 +67,47 @@ class TestComponent {
});
}
```
+
+If we want to get the value for a specific query param and transform it into any shape, we can pass the name of the query param and a `transform` function.
+
+```ts
+@Component({
+ template: `
+ Number: {{ number1() }} New number: {{ newNumber() }}
+ `,
+})
+cl... | I'd move this to a new section in docs. |
ngxtension-platform | github_2023 | others | 232 | ngxtension | eneajaho | @@ -67,3 +67,47 @@ class TestComponent {
});
}
```
+
+If we want to get the value for a specific query param and transform it into any shape, we can pass the name of the query param and a `transform` function.
+
+```ts
+@Component({
+ template: `
+ Number: {{ number1() }} New number: {{ newNumber() }}
+ `,
+})
+cl... | Can we change this to computedAsync? |
ngxtension-platform | github_2023 | others | 232 | ngxtension | eneajaho | @@ -45,25 +63,136 @@ If we want to get the value for a specific query param, we can pass the name of
class TestComponent {
searchParam = injectQueryParams('search'); // returns a signal with the value of the search query param
- filteredUsers = computedFrom(
- [this.searchParam],
- switchMap((searchQuery) =>
- ... | ```suggestion
() => this.userService.getUsers(this.searchParam() ?? ''),
``` |
ngxtension-platform | github_2023 | others | 232 | ngxtension | eneajaho | @@ -45,25 +63,136 @@ If we want to get the value for a specific query param, we can pass the name of
class TestComponent {
searchParam = injectQueryParams('search'); // returns a signal with the value of the search query param
- filteredUsers = computedFrom(
- [this.searchParam],
- switchMap((searchQuery) =>
- ... | I'd like to have examples which are meaningful. So let's convert this to a pageNumber and use better var names.
```suggestion
pageNumber = injectQueryParams('pageNumber', { transform: numberAttribute });
```
|
ngxtension-platform | github_2023 | others | 232 | ngxtension | eneajaho | @@ -45,25 +63,136 @@ If we want to get the value for a specific query param, we can pass the name of
class TestComponent {
searchParam = injectQueryParams('search'); // returns a signal with the value of the search query param
- filteredUsers = computedFrom(
- [this.searchParam],
- switchMap((searchQuery) =>
- ... | ```suggestion
``` |
ngxtension-platform | github_2023 | others | 232 | ngxtension | eneajaho | @@ -45,25 +63,136 @@ If we want to get the value for a specific query param, we can pass the name of
class TestComponent {
searchParam = injectQueryParams('search'); // returns a signal with the value of the search query param
- filteredUsers = computedFrom(
- [this.searchParam],
- switchMap((searchQuery) =>
- ... | ```suggestion
filteredUsers = computedAsync(() => this.userService.getUsers(this.searchParam()), {
``` |
ngxtension-platform | github_2023 | typescript | 301 | ngxtension | kbrilla | @@ -0,0 +1,316 @@
+import {
+ Tree,
+ formatFiles,
+ getProjects,
+ logger,
+ readJson,
+ readProjectConfiguration,
+ visitNotIgnoredFiles,
+} from '@nx/devkit';
+import { readFileSync } from 'node:fs';
+import { exit } from 'node:process';
+import {
+ CodeBlockWriter,
+ Decorator,
+ Node,
+ Project,
+ WriterFunction,
... | needs to be `if (genericTypeOnEmitter?.length) {`
as `genericTypeOnEmitter` can be undefined
with this migration run locally
|
ngxtension-platform | github_2023 | typescript | 301 | ngxtension | kbrilla | @@ -0,0 +1,316 @@
+import {
+ Tree,
+ formatFiles,
+ getProjects,
+ logger,
+ readJson,
+ readProjectConfiguration,
+ visitNotIgnoredFiles,
+} from '@nx/devkit';
+import { readFileSync } from 'node:fs';
+import { exit } from 'node:process';
+import {
+ CodeBlockWriter,
+ Decorator,
+ Node,
+ Project,
+ WriterFunction,
... | after `node.replaceWithText(newProperty.print());`
this code is needed for something like 'this.someOutput.next() to be replaced with this.someOutput.emit()' as this was actually possible on EventEmiter
```
newProperty.findReferencesAsNodes().forEach((reference) => {
try {
//we are looking for ... |
ngxtension-platform | github_2023 | typescript | 277 | ngxtension | renatoaraujoc | @@ -0,0 +1,12 @@
+import { signal } from '@angular/core';
+
+export function createNotifier() { | `createNotifier()` is fine, but I'd give more context to the name like I mentioned on the discussion, like:
`createManualSignalNotifier()` or just `createSignalNotifier()`.
Just a matter of preference though, `createNotifier()` is also fine. |
ngxtension-platform | github_2023 | typescript | 277 | ngxtension | renatoaraujoc | @@ -0,0 +1,12 @@
+import { signal } from '@angular/core';
+
+export function createNotifier() {
+ const sourceSignal = signal(0); | Could think about something like, maybe:
```typescript
const sourceSignal = signal<'FIRST_EMISSION' | number>('FIRST_EMISSION'); // or 'INIT'?
// Then on the notify() updater
return {
notify: () => {
sourceSignal.update((v) => v === 'FIRST_EMISSION' ? 0 : (v+1)); // narrowing ftw :D
},
listen: sour... |
ngxtension-platform | github_2023 | typescript | 259 | ngxtension | LcsGa | @@ -0,0 +1,114 @@
+import { Injector, isSignal, untracked, type Signal } from '@angular/core';
+import { toObservable, toSignal } from '@angular/core/rxjs-interop';
+import { assertInjector } from 'ngxtension/assert-injector';
+import {
+ distinctUntilChanged,
+ from,
+ isObservable,
+ merge,
+ startWith,
+ type Observ... | You can simplify this with the `identity` operator from rxjs
```suggestion
const merged = merge(...normalizedSources).pipe(operator ?? identity);
```
|
ngxtension-platform | github_2023 | others | 259 | ngxtension | eneajaho | @@ -0,0 +1,42 @@
+---
+title: mergeFrom
+description: ngxtension/merge-from
+entryPoint: merge-from
+badge: stable
+contributors: ['chau-tran']
+---
+
+`mergeFrom` is a helper function that merges the values of `Observable`s or `Signal`s and emits the latest emitted value.
+It also gives us the possibility to change th... | Should we add a TODO here and open an issue to showcase these ways with examples?
|
ngxtension-platform | github_2023 | typescript | 255 | ngxtension | JeanMeche | @@ -72,46 +82,160 @@ interface ComputedAsyncOptions<T> extends CreateComputedOptions<T> {
* @param computation
* @param options
*/
+
+// Base case: no options -> `undefined` in the result type
+export function computedAsync<T>(
+ computation: (
+ previousValue?: T | undefined,
+ ) => Promise<T> | Observable<T> |... | I'd use curly braces if this doesn't fit as a oneliner |
ngxtension-platform | github_2023 | typescript | 255 | ngxtension | JeanMeche | @@ -72,46 +82,160 @@ interface ComputedAsyncOptions<T> extends CreateComputedOptions<T> {
* @param computation
* @param options
*/
+
+// Base case: no options -> `undefined` in the result type
+export function computedAsync<T>(
+ computation: (
+ previousValue?: T | undefined,
+ ) => Promise<T> | Observable<T> |... | This pattern feels a bit weird, maybe add a comment on why this. |
ngxtension-platform | github_2023 | typescript | 255 | ngxtension | JeanMeche | @@ -122,31 +246,46 @@ export function computedAsync<T>(
options?.behavior ?? 'switch',
);
- const sourceResult = source$.subscribe({
- next: (value) => sourceValue.set(value),
- error: (error) => {
+ const sourceResult = source$
+ // we skip the first value if requireSync is true because we already set... | ```suggestion
if (options?.requireSync && sourceValue().kind === StateKind.NoValue) {
```
Looks like the assertion isn't required |
ngxtension-platform | github_2023 | typescript | 255 | ngxtension | JeanMeche | @@ -122,31 +246,46 @@ export function computedAsync<T>(
options?.behavior ?? 'switch',
);
- const sourceResult = source$.subscribe({
- next: (value) => sourceValue.set(value),
- error: (error) => {
+ const sourceResult = source$
+ // we skip the first value if requireSync is true because we already set... | maybe add a `default` in case ? |
ngxtension-platform | github_2023 | typescript | 255 | ngxtension | nartc | @@ -72,46 +96,157 @@ interface ComputedAsyncOptions<T> extends CreateComputedOptions<T> {
* @param computation
* @param options
*/
+
+// Base case: no options -> `undefined` in the result type
+export function computedAsync<T>(
+ computation: (
+ previousValue?: T | undefined,
+ ) => Promise<T> | Observable<T> |... | suggestion: no assertion needed
```suggestion
if (sourceValue().kind === StateKind.NoValue)
``` |
ngxtension-platform | github_2023 | typescript | 255 | ngxtension | nartc | @@ -72,46 +96,157 @@ interface ComputedAsyncOptions<T> extends CreateComputedOptions<T> {
* @param computation
* @param options
*/
+
+// Base case: no options -> `undefined` in the result type
+export function computedAsync<T>(
+ computation: (
+ previousValue?: T | undefined,
+ ) => Promise<T> | Observable<T> |... | nit: I would personally set this to be an empty object.
```suggestion
options: any = {}
``` |
ngxtension-platform | github_2023 | typescript | 255 | ngxtension | nartc | @@ -72,46 +96,157 @@ interface ComputedAsyncOptions<T> extends CreateComputedOptions<T> {
* @param computation
* @param options
*/
+
+// Base case: no options -> `undefined` in the result type
+export function computedAsync<T>(
+ computation: (
+ previousValue?: T | undefined,
+ ) => Promise<T> | Observable<T> |... | nit: can be merged
```suggestion
const currentValue = untracked(() => {
const { kind, value } = sourceValue();
return kind === StateKind.Value ? value : undefined;
});
``` |
ngxtension-platform | github_2023 | typescript | 255 | ngxtension | nartc | @@ -72,46 +96,157 @@ interface ComputedAsyncOptions<T> extends CreateComputedOptions<T> {
* @param computation
* @param options
*/
+
+// Base case: no options -> `undefined` in the result type
+export function computedAsync<T>(
+ computation: (
+ previousValue?: T | undefined,
+ ) => Promise<T> | Observable<T> |... | nit: this is not needed because `assertInjector` ensures this `effect()` runs in the provided Injector if it was provided |
ngxtension-platform | github_2023 | typescript | 255 | ngxtension | nartc | @@ -122,31 +257,48 @@ export function computedAsync<T>(
options?.behavior ?? 'switch',
);
- const sourceResult = source$.subscribe({
- next: (value) => sourceValue.set(value),
- error: (error) => {
+ const sourceResult = source$
+ // we skip the first value if requireSync is true because we already set... | nit: feel like `effectRef.destroy()` isn't needed |
ngxtension-platform | github_2023 | typescript | 255 | ngxtension | nartc | @@ -122,31 +257,48 @@ export function computedAsync<T>(
options?.behavior ?? 'switch',
);
- const sourceResult = source$.subscribe({
- next: (value) => sourceValue.set(value),
- error: (error) => {
+ const sourceResult = source$
+ // we skip the first value if requireSync is true because we already set... | question: why do we throw `REQUIRE_SYNC` error here without checking for `options.requiredSync`? |
ngxtension-platform | github_2023 | others | 242 | ngxtension | ajitzero | @@ -1,59 +1,75 @@
---
import { Icon } from '@astrojs/starlight/components';
-interface Props {
+interface Contributor {
name: string;
twitter?: string;
linkedin?: string;
github?: string;
website?: string;
}
-const { name, twitter, linkedin, github, website } = Astro.props;
+interface Props {
+ contrib... | Minor/question: Do we need to mention `data` in the type?
`contributors` is supposed to have `Contributor[]` type, but seems to have `{ data: Contributor[] }` instead. Is this something specific to Astro? |
ngxtension-platform | github_2023 | others | 242 | ngxtension | nartc | @@ -4,12 +4,16 @@ import type { Props } from '@astrojs/starlight/props';
import { getEntry } from 'astro:content';
import Contributor from './Contributor.astro';
-const contributor = Astro.props.entry.data.contributor
- ? await getEntry(Astro.props.entry.data.contributor)
+const contributors = Astro.props.entry.dat... | nit: rename the component to `Contributors` |
ngxtension-platform | github_2023 | typescript | 239 | ngxtension | nartc | @@ -0,0 +1,32 @@
+import {
+ InjectionToken,
+ type EnvironmentProviders,
+ type Provider,
+} from '@angular/core';
+import {
+ createInjectionToken,
+ type CreateInjectionTokenDeps,
+ type CreateInjectionTokenOptions,
+} from 'ngxtension/create-injection-token';
+
+export type CreateInjectableOptions<
+ TFactory exten... | this won't work because `[2]` is just an `InjectionToken`. It cannot be used on its own in the `providers` array. We'd need a different implementation or adjust `createInjectionToken` somehow |
ngxtension-platform | github_2023 | others | 239 | ngxtension | spierala | @@ -0,0 +1,57 @@
+---
+title: createInjectable
+description: A function based approach for creating Injectable services
+entryPoint: create-injectable
+badge: experimental
+contributor: josh-morony
+---
+
+`createInjectable` uses `createInjectionToken` behind the scenes as a way to
+create injectable services and other... | Looking at the code, I think that `createInjectable` does not return an Array anymore. |
ngxtension-platform | github_2023 | typescript | 239 | ngxtension | spierala | @@ -0,0 +1,42 @@
+import { inject } from '@angular/core';
+import { TestBed } from '@angular/core/testing';
+import { createInjectable } from './create-injectable';
+
+describe(createInjectable.name, () => {
+ it('should be able to access property returned from injectable', () => {
+ let count = 0;
+ const MyInjectab... | Maybe it could be useful to inject `MyInjectable` two times... and then check that count does not increment anymore after the first injection.
Then we are quite sure that it is a Singleton service.
Same thing could be done for the non-root injectable, but there we would expect that the count is incremented for ev... |
ngxtension-platform | github_2023 | typescript | 229 | ngxtension | ribizli | @@ -0,0 +1,158 @@
+import {
+ DestroyRef,
+ Injector,
+ computed,
+ effect,
+ inject,
+ signal,
+ untracked,
+ type CreateComputedOptions,
+ type Signal,
+} from '@angular/core';
+import { assertInjector } from 'ngxtension/assert-injector';
+import {
+ Observable,
+ Subject,
+ concatMap,
+ exhaustMap,
+ isObservable,
+... | why this `untracked` is needed? I think no signal is called here at all. |
ngxtension-platform | github_2023 | typescript | 229 | ngxtension | hoc081098 | @@ -0,0 +1,158 @@
+import {
+ DestroyRef,
+ Injector,
+ computed,
+ effect,
+ inject,
+ signal,
+ untracked,
+ type CreateComputedOptions,
+ type Signal,
+} from '@angular/core';
+import { assertInjector } from 'ngxtension/assert-injector';
+import {
+ Observable,
+ Subject,
+ concatMap,
+ exhaustMap,
+ isObservable,
+... | I think `mergeAll`, `switchAll`, `exhaustAll` and `concatAll` can be used instead of `mergeMap((s) => s`, ... |
ngxtension-platform | github_2023 | typescript | 229 | ngxtension | LcsGa | @@ -0,0 +1,158 @@
+import {
+ DestroyRef,
+ Injector,
+ computed,
+ effect,
+ inject,
+ signal,
+ untracked,
+ type CreateComputedOptions,
+ type Signal,
+} from '@angular/core';
+import { assertInjector } from 'ngxtension/assert-injector';
+import {
+ Observable,
+ Subject,
+ concatMap,
+ exhaustMap,
+ isObservable,
+... | There is no need to throw the error here, it is just an error notification. The error is not caught. |
ngxtension-platform | github_2023 | typescript | 229 | ngxtension | LcsGa | @@ -0,0 +1,158 @@
+import {
+ DestroyRef,
+ Injector,
+ computed,
+ effect,
+ inject,
+ signal,
+ untracked,
+ type CreateComputedOptions,
+ type Signal,
+} from '@angular/core';
+import { assertInjector } from 'ngxtension/assert-injector';
+import {
+ Observable,
+ Subject,
+ concatMap,
+ exhaustMap,
+ isObservable,
+... | ```suggestion
if (!isObservable(newSource) && !isPromise(newSource)) {
// if the new source is not an observable or a promise, we set the value immediately
untracked(() => sourceValue.set(newSource));
} else {
// we untrack the source$.next() so that we don't register other signals as dep... |
ngxtension-platform | github_2023 | typescript | 219 | ngxtension | nartc | @@ -0,0 +1,471 @@
+import {
+ Directive,
+ ENVIRONMENT_INITIALIZER,
+ ElementRef,
+ Injectable,
+ Injector,
+ Input,
+ NgZone,
+ booleanAttribute,
+ computed,
+ effect,
+ inject,
+ makeEnvironmentProviders,
+ runInInjectionContext,
+ signal,
+ type OnInit,
+} from '@angular/core';
+import { toObservable, toSignal } fro... | nit/question: I'm not too familiar with `DOMParser`. Can we just instantiate `DOMParser` once instead? |
ngxtension-platform | github_2023 | typescript | 219 | ngxtension | nartc | @@ -0,0 +1,471 @@
+import {
+ Directive,
+ ENVIRONMENT_INITIALIZER,
+ ElementRef,
+ Injectable,
+ Injector,
+ Input,
+ NgZone,
+ booleanAttribute,
+ computed,
+ effect,
+ inject,
+ makeEnvironmentProviders,
+ runInInjectionContext,
+ signal,
+ type OnInit,
+} from '@angular/core';
+import { toObservable, toSignal } fro... | comment (non-blocking): there's `autoEffect` in `ngxtension/auto-effect` that you can use if you don't want to inject the `Injector` and `runInInjectionContext` manually 😛 |
ngxtension-platform | github_2023 | typescript | 219 | ngxtension | nartc | @@ -0,0 +1,471 @@
+import {
+ Directive,
+ ENVIRONMENT_INITIALIZER,
+ ElementRef,
+ Injectable,
+ Injector,
+ Input,
+ NgZone,
+ booleanAttribute,
+ computed,
+ effect,
+ inject,
+ makeEnvironmentProviders,
+ runInInjectionContext,
+ signal,
+ type OnInit,
+} from '@angular/core';
+import { toObservable, toSignal } fro... | nit: let's `inject(DOCUMENT)` for this |
ngxtension-platform | github_2023 | typescript | 219 | ngxtension | nartc | @@ -0,0 +1,471 @@
+import {
+ Directive,
+ ENVIRONMENT_INITIALIZER,
+ ElementRef,
+ Injectable,
+ Injector,
+ Input,
+ NgZone,
+ booleanAttribute,
+ computed,
+ effect,
+ inject,
+ makeEnvironmentProviders,
+ runInInjectionContext,
+ signal,
+ type OnInit,
+} from '@angular/core';
+import { toObservable, toSignal } fro... | nit: explicit type is redundant |
ngxtension-platform | github_2023 | typescript | 219 | ngxtension | nartc | @@ -0,0 +1,471 @@
+import {
+ Directive,
+ ENVIRONMENT_INITIALIZER,
+ ElementRef,
+ Injectable,
+ Injector,
+ Input,
+ NgZone,
+ booleanAttribute,
+ computed,
+ effect,
+ inject,
+ makeEnvironmentProviders,
+ runInInjectionContext,
+ signal,
+ type OnInit,
+} from '@angular/core';
+import { toObservable, toSignal } fro... | suggestion: since `this.sprites.get()` returns the sprite from a Record, we won't get a runtime error and will just get `undefined` if the sprite isn't there. Feel free to skip this suggestion though if you think explicitly checking for null is better.
```suggestion
return this.sprites.get(this.sprite$());
``` |
ngxtension-platform | github_2023 | typescript | 219 | ngxtension | nartc | @@ -0,0 +1,471 @@
+import {
+ Directive,
+ ENVIRONMENT_INITIALIZER,
+ ElementRef,
+ Injectable,
+ Injector,
+ Input,
+ NgZone,
+ booleanAttribute,
+ computed,
+ effect,
+ inject,
+ makeEnvironmentProviders,
+ runInInjectionContext,
+ signal,
+ type OnInit,
+} from '@angular/core';
+import { toObservable, toSignal } fro... | comment (non-blocking): I almost believe we can use `computedFrom` for this? |
ngxtension-platform | github_2023 | typescript | 219 | ngxtension | nartc | @@ -0,0 +1,471 @@
+import {
+ Directive,
+ ENVIRONMENT_INITIALIZER,
+ ElementRef,
+ Injectable,
+ Injector,
+ Input,
+ NgZone,
+ booleanAttribute,
+ computed,
+ effect,
+ inject,
+ makeEnvironmentProviders,
+ runInInjectionContext,
+ signal,
+ type OnInit,
+} from '@angular/core';
+import { toObservable, toSignal } fro... | nit/suggestion: I think `provideSvgSprites([createSvgSprite()])` is a little verbose. Can't we accept literal objects from the consumers and run `createSvgSprite` internally? In other words, keep `createSvgSprite` an internal API (so one less thing the consumers should care about) |
ngxtension-platform | github_2023 | others | 215 | ngxtension | eneajaho | @@ -45,10 +45,13 @@ export class Form {
lastName: new FormControl({ value: '', disabled: true }),
});
- readonly #toggleLastNameAccess = rxEffect(this.user.controls.firstName.valueChanges, (firstName) => {
- if (firstName) this.user.controls.lastName.enable();
- else this.user.controls.lastName.disable();
- })... | ```suggestion
if (firstName) this.user.controls.lastName.enable();
else this.user.controls.lastName.disable();
``` |
ngxtension-platform | github_2023 | typescript | 216 | ngxtension | nartc | @@ -0,0 +1,64 @@
+import {
+ computed,
+ signal,
+ type Signal,
+ type WritableSignal,
+} from '@angular/core';
+
+/**
+ * Creates a writable signal with a `value` property.
+ *
+ * @example
+ * const state = createSignal({ count: 0 });
+ *
+ * effect(() => {
+ * // Works as expected
+ * console.log(state.value.count... | nit/suggestion: let's change this to `defineProperty` instead
```suggestion
return Object.defineProperty(sig, 'value', {
get: sig.asReadonly(),
set: sig.set.bind(sig),
}) as WritableSignal<T> & { value: T };
``` |
ngxtension-platform | github_2023 | typescript | 216 | ngxtension | nartc | @@ -0,0 +1,56 @@
+import {
+ computed,
+ signal,
+ type Signal,
+ type WritableSignal,
+} from '@angular/core';
+
+/**
+ * Creates a writable signal with a `value` property.
+ *
+ * @example
+ * const state = createSignal({ count: 0 });
+ *
+ * effect(() => {
+ * // Works as expected
+ * console.log(state.value.count... | nit: c'mon boi! why not change this here as well xD |
ngxtension-platform | github_2023 | typescript | 211 | ngxtension | ajitzero | @@ -51,10 +51,10 @@ export function injectDocumentVisibility(
const docVisible$: Observable<DocumentVisibilityState> = fromEvent(
doc,
- 'visibilitychange',
+ 'visibilitychange'
).pipe(
startWith(doc.visibilityState),
- map(() => doc.visibilityState),
+ map(() => doc.visibilityState) | Hi @fiorelozere - I see minor Prettier issues here. Could you please run `nx format:write` locally (with the latest node modules)? This might be an existing miss prior to your changes. |
ngxtension-platform | github_2023 | typescript | 205 | ngxtension | nartc | @@ -60,7 +60,13 @@ export function hostBinding<T, S extends Signal<T> | WritableSignal<T>>(
);
break;
case 'attr':
- renderer.setAttribute(element, property, String(value));
+ const v = value ?? null;
+
+ if (v === null) { | nit: maybe we can just `== null` check for `value` to remove attribute if `value` is `undefined` or `null`? |
ngxtension-platform | github_2023 | others | 199 | ngxtension | nelsongutidev | @@ -0,0 +1,133 @@
+---
+title: injectDestroy
+description: ngxtension/inject-destroy
+badge: stable
+contributor: enea-jahollari
+---
+
+`injectDestroy` es una función auxiliar que devuelve un observable que emite cuando el componente se destruye.
+
+Nos ayuda a evitar las fugas de memoria cancelando la suscripción de ... | Looks like we missed removing the original English line, can we remove it? |
ngxtension-platform | github_2023 | others | 199 | ngxtension | nelsongutidev | @@ -0,0 +1,240 @@
+---
+title: createInjectionToken
+description: Crea un InjectionToken y devuelve un injectFn y provideFn para el mismo.
+badge: stable
+contributor: chau-tran
+---
+
+`createInjectionToken` es una abstacción sobre la creación de un [`InjectionToken`](https://angular.io/api/core/InjectionToken) y devu... | Looks like this one is translated up until this line, it is also a large one, is this intentional? |
ngxtension-platform | github_2023 | others | 199 | ngxtension | nelsongutidev | @@ -0,0 +1,121 @@
+---
+title: injectLazy
+description: ngxtension/inject-lazy
+badge: stable
+contributor: enea-jahollari
+---
+
+`injectLazy` es una función auxiliar que nos permite lazy-load un servicio o cualquier tipo de proveedor de Angular.
+
+El lazy loading de servicios es útil cuando queremos reducir el tamañ... | Looks like we missed removing the English portion of this line, can we remove it? |
ngxtension-platform | github_2023 | typescript | 186 | ngxtension | nartc | @@ -0,0 +1,181 @@
+import { DOCUMENT } from '@angular/common';
+import type { Injector, Signal, WritableSignal } from '@angular/core';
+import { inject, runInInjectionContext, signal } from '@angular/core';
+import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
+import { assertInjector } from 'ngxtension/ass... | ```suggestion
connect(online, online$);
``` |
ngxtension-platform | github_2023 | typescript | 186 | ngxtension | nartc | @@ -0,0 +1,181 @@
+import { DOCUMENT } from '@angular/common';
+import type { Injector, Signal, WritableSignal } from '@angular/core';
+import { inject, runInInjectionContext, signal } from '@angular/core';
+import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
+import { assertInjector } from 'ngxtension/ass... | ```suggestion
connect(online, offline$);
``` |
ngxtension-platform | github_2023 | typescript | 186 | ngxtension | nartc | @@ -0,0 +1,181 @@
+import { DOCUMENT } from '@angular/common';
+import type { Injector, Signal, WritableSignal } from '@angular/core';
+import { inject, runInInjectionContext, signal } from '@angular/core';
+import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
+import { assertInjector } from 'ngxtension/ass... | ```suggestion
const offlineAt = signal<number | undefined>(undefined);
const onlineAt = signal<number | undefined>(undefined);
const downlink = signal<number | undefined>(undefined);
const downlinkMax = signal<number | undefined>(undefined);
const rtt = signal<number | undefined>(undefined);
const eff... |
ngxtension-platform | github_2023 | typescript | 186 | ngxtension | nartc | @@ -0,0 +1,181 @@
+import { DOCUMENT } from '@angular/common';
+import type { Injector, Signal, WritableSignal } from '@angular/core';
+import { inject, runInInjectionContext, signal } from '@angular/core';
+import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
+import { assertInjector } from 'ngxtension/ass... | ```suggestion
| '5g';
``` |
ngxtension-platform | github_2023 | typescript | 186 | ngxtension | nartc | @@ -0,0 +1,181 @@
+import { DOCUMENT } from '@angular/common';
+import type { Injector, Signal, WritableSignal } from '@angular/core';
+import { inject, runInInjectionContext, signal } from '@angular/core'; | ```suggestion
import { inject, runInInjectionContext, signal, type Injector, type Signal } from '@angular/core';
``` |
ngxtension-platform | github_2023 | typescript | 188 | ngxtension | joshuamorony | @@ -140,7 +140,15 @@ export function signalSlice<
| ((state: Signal<TSignalValue>) => Source<TSignalValue>)
>;
actionSources?: TActionSources;
- selectors?: (state: Signal<TSignalValue>) => TSelectors;
+ selectors?: (
+ state: SignalSlice<
+ TSignalValue,
+ TActionSources,
+ TSelectors,
+ any,
+ TActi... | ```suggestion
selectors?: (
state: SignalSlice<
TSignalValue,
TActionSources,
any,
TEffects,
TActionEffects
>
) => TSelectors;
``` |
ngxtension-platform | github_2023 | typescript | 184 | ngxtension | eneajaho | @@ -0,0 +1,64 @@
+import { DOCUMENT } from '@angular/common';
+import {
+ Injector,
+ inject,
+ runInInjectionContext,
+ type Signal,
+} from '@angular/core';
+import { toSignal } from '@angular/core/rxjs-interop';
+import { assertInjector } from 'ngxtension/assert-injector';
+import { Observable, fromEvent, map, start... | ```suggestion
effect(() => {
console.log(this.visibilityState());
});
``` |
ngxtension-platform | github_2023 | typescript | 184 | ngxtension | nartc | @@ -0,0 +1,18 @@
+import { Component, effect } from '@angular/core';
+import { injectDocumentVisibility } from '../../../../../libs/ngxtension/document-visibility-state/src/document-visibility-state'; | issue: this gotta be imported from `ngxtension/document-visibility-state` |
ngxtension-platform | github_2023 | others | 179 | ngxtension | ajitzero | @@ -4,11 +4,12 @@ import { Icon } from '@astrojs/starlight/components';
interface Props {
name: string;
twitter?: string;
- linkedin?: string;
- github?: string;
+ linkedin?: string;
+ github?: string;
+ website?: string; | Looks like Prettier didn't run here |
ngxtension-platform | github_2023 | others | 174 | ngxtension | ajitzero | @@ -0,0 +1,41 @@
+---
+import { Icon } from '@astrojs/starlight/components';
+
+interface Props {
+ name: string;
+ twitter?: string;
+ linkedin?: string;
+ github?: string; | Minor: Later, when the contributors' data are added to the JSON files, we can mark this field as required.
Edit: This is more of reminder/note, please ignore |
ngxtension-platform | github_2023 | others | 174 | ngxtension | ajitzero | @@ -0,0 +1,6 @@
+{
+ "name": "Thomas Laforge",
+ "twitter": "https://twitter.com/laforge_toma",
+ "linkedin": "https://www.linkedin.com/in/thomas-laforge-2b05a945/",
+ "github": "https://github.com/tomalaforge"
+} | Suggestion/Question: Should we consider only saving the username parts and creating the actual URLs in `Contributor.astro`? |
ngxtension-platform | github_2023 | typescript | 174 | ngxtension | ajitzero | @@ -1,13 +1,28 @@
import { docsSchema, i18nSchema } from '@astrojs/starlight/schema';
-import { defineCollection, z } from 'astro:content';
+import { defineCollection, reference, z } from 'astro:content';
-export const collections = {
- docs: defineCollection({
- schema: (ctx) =>
- docsSchema()(ctx).extend({
- ... | nit: I prefer the [shorthand](https://javascript.info/object#property-value-shorthand), mainly due to [this ES Lint rule](https://eslint.org/docs/latest/rules/object-shorthand). I have no strong opinions on this though.
```suggestion
docs,
i18n,
contributors,
``` |
ngxtension-platform | github_2023 | typescript | 149 | ngxtension | JeanMeche | @@ -0,0 +1,62 @@
+import { inject, type Signal } from '@angular/core';
+import { toSignal } from '@angular/core/rxjs-interop';
+import { ActivatedRoute, type Params } from '@angular/router';
+import { map, startWith } from 'rxjs';
+
+/**
+ * Injects the params from the current route.
+ */
+export function injectParams(... | wouldn't the default value make it more reable ? (and also drop the `startWith` import) |
ngxtension-platform | github_2023 | typescript | 149 | ngxtension | JeanMeche | @@ -0,0 +1,62 @@
+import { inject, type Signal } from '@angular/core';
+import { toSignal } from '@angular/core/rxjs-interop';
+import { ActivatedRoute, type Params } from '@angular/router';
+import { map, startWith } from 'rxjs';
+
+/**
+ * Injects the params from the current route.
+ */
+export function injectParams(... | nit: maybe drop that `any` ? |
ngxtension-platform | github_2023 | typescript | 149 | ngxtension | JeanMeche | @@ -0,0 +1,67 @@
+import { inject, type Signal } from '@angular/core';
+import { toSignal } from '@angular/core/rxjs-interop';
+import { ActivatedRoute, type Params } from '@angular/router';
+import { map, startWith } from 'rxjs';
+
+/**
+ * Injects the query params from the current route.
+ */
+export function injectQ... | By replacing any, you wont have to do this type assertion ! |
ngxtension-platform | github_2023 | typescript | 149 | ngxtension | JeanMeche | @@ -0,0 +1,56 @@
+import { inject, type Signal } from '@angular/core';
+import { toSignal } from '@angular/core/rxjs-interop';
+import { ActivatedRoute, type Params } from '@angular/router';
+import { map } from 'rxjs';
+
+/**
+ * Injects the params from the current route.
+ */
+export function injectParams(): Signal<P... | Wdyt of this ?
```suggestion
keyOrTransform ? params?.[keyOrTransform] ?? null : params;
``` |
ngxtension-platform | github_2023 | others | 144 | ngxtension | nartc | @@ -101,6 +101,30 @@ The associated action can then be triggered with:
this.state.toggleActive();
```
+## Async Reducers
+
+A standard reducer accepts a function that updates the state synchronously. It
+is also possible to specify `asyncReducers` that return an observable to update
+the state asynchronously.
+
+Fo... | ```suggestion
load: (_state, $: Observable<void>) => $.pipe(
``` |
ngxtension-platform | github_2023 | others | 122 | ngxtension | eneajaho | @@ -39,7 +40,8 @@ It can be used in multiple ways:
1. Combine multiple `Signal`s
2. Combine multiple `Observable`s
3. Combine multiple `Signal`s and `Observable`s
-4. Use it outside of an injection context
+4. Use of options initialValue | ```suggestion
4. Using initialValue param
``` |
ngxtension-platform | github_2023 | others | 122 | ngxtension | eneajaho | @@ -71,7 +73,8 @@ let c = computedFrom(
([a, b]) =>
// of(a + b) is supposed to be an asynchronous operation (e.g. http request)
of(a + b).pipe(delay(1000)) // delay the emission of the combined value by 1 second for demonstration purposes
- )
+ ),
+ { initialValue: 42 } // change the initial value of ... | I'd like to have this here as is. And add another example where we use initial value to showcase how it changes the output. |
ngxtension-platform | github_2023 | others | 122 | ngxtension | eneajaho | @@ -87,28 +90,28 @@ setTimeout(() => {
The console log will be:
```ts
--[1, 2] - // initial value
+42 - // initial value
3 - // combined value after 1 second
5; // combined value after 3 seconds
```
-As we can see, the first value will not be affected by the rxjs operators, because they are asynchronous and ... | ```suggestion
As we can see, we passed an `initialValue` as the third argument, to prevent _throwing an error_ in case of an observable that will **not have a sync value** because they emit later their values.
``` |
ngxtension-platform | github_2023 | others | 122 | ngxtension | eneajaho | @@ -151,15 +154,13 @@ console.log(combinedObject()); // { page: 1, filters: { name: 'John' } }
```
:::note[Tricky part]
-For `Observable`s that don't emit synchronously, `computedFrom` will give us null as the initial value for the `Observable`s.
+For `Observable`s that don't emit synchronously `computedFrom` will ... | ```suggestion
For `Observable`s that don't emit synchronously `computedFrom` will **throw an error** forcing you to fix this situation either by passing an `initialValue` in the third argument, or using `startWith` operator to force observable to have a sync starting value.
``` |
ngxtension-platform | github_2023 | others | 122 | ngxtension | eneajaho | @@ -151,15 +154,13 @@ console.log(combinedObject()); // { page: 1, filters: { name: 'John' } }
```
:::note[Tricky part]
-For `Observable`s that don't emit synchronously, `computedFrom` will give us null as the initial value for the `Observable`s.
+For `Observable`s that don't emit synchronously `computedFrom` will ... | ```suggestion
const combined = computedFrom([page$, filters$]); // 👈 will throw an error!! 💥
``` |
ngxtension-platform | github_2023 | others | 122 | ngxtension | eneajaho | @@ -173,9 +174,20 @@ const combined = computedFrom([
console.log(combined()); // [0, { name: 'John' }]
```
-### 4. Use it outside of an injection context
+### 4. Use of options initialValue | ```suggestion
### 4. Using initialValue param
``` |
ngxtension-platform | github_2023 | typescript | 122 | ngxtension | eneajaho | @@ -25,6 +25,7 @@ import {
switchMap,
} from 'rxjs';
import { computedFrom } from './computed-from';
+import exp = require('constants'); | Is this needed? |
ngxtension-platform | github_2023 | typescript | 122 | ngxtension | eneajaho | @@ -58,6 +59,30 @@ describe(computedFrom.name, () => {
expect(s()).toEqual([1]);
});
});
+ it(`MD FIX for Observables that don't emit synchronously, computedFrom will THROW ERROR`, () => {
+ TestBed.runInInjectionContext(() => {
+ const late = of(1).pipe(delay(1000)); // late emit after 1s
+ expect... | ```suggestion
}).toThrowError(/requireSync/i); // Throw error NG0601 due to `toSignal` + `requireSync: true`
``` |
ngxtension-platform | github_2023 | typescript | 122 | ngxtension | eneajaho | @@ -58,6 +59,30 @@ describe(computedFrom.name, () => {
expect(s()).toEqual([1]);
});
});
+ it(`MD FIX for Observables that don't emit synchronously, computedFrom will THROW ERROR`, () => {
+ TestBed.runInInjectionContext(() => {
+ const late = of(1).pipe(delay(1000)); // late emit after 1s
+ expect... | Can you use normal lowercase sentences, please?
Uppercase is not easy to read. |
ngxtension-platform | github_2023 | typescript | 122 | ngxtension | eneajaho | @@ -58,6 +59,30 @@ describe(computedFrom.name, () => {
expect(s()).toEqual([1]);
});
});
+ it(`MD FIX for Observables that don't emit synchronously, computedFrom will THROW ERROR`, () => {
+ TestBed.runInInjectionContext(() => {
+ const late = of(1).pipe(delay(1000)); // late emit after 1s
+ expect... | What is MD ? |
ngxtension-platform | github_2023 | typescript | 122 | ngxtension | eneajaho | @@ -59,53 +86,82 @@ export function computedFrom<Input extends object, Output = Input>(
* }
* ```
*/
-export function computedFrom(
- sources: any,
- operator?: OperatorFunction<any, any>,
- injector?: Injector
-): Signal<any> {
+export function computedFrom<Input = any, Output = Input>(
+ ...args: any[]
+): Sign... | Can you convert the text to lowercase, please? |
ngxtension-platform | github_2023 | typescript | 122 | ngxtension | eneajaho | @@ -59,53 +86,82 @@ export function computedFrom<Input extends object, Output = Input>(
* }
* ```
*/
-export function computedFrom(
- sources: any,
- operator?: OperatorFunction<any, any>,
- injector?: Injector
-): Signal<any> {
+export function computedFrom<Input = any, Output = Input>(
+ ...args: any[]
+): Sign... | @nartc What do you think about this one?
I think we will need sth like this. |
ngxtension-platform | github_2023 | typescript | 122 | ngxtension | eneajaho | @@ -59,53 +86,82 @@ export function computedFrom<Input extends object, Output = Input>(
* }
* ```
*/
-export function computedFrom(
- sources: any,
- operator?: OperatorFunction<any, any>,
- injector?: Injector
-): Signal<any> {
+export function computedFrom<Input = any, Output = Input>(
+ ...args: any[]
+): Sign... | ```suggestion
throw new TypeError('computedFrom needs sources');
``` |
ngxtension-platform | github_2023 | typescript | 122 | ngxtension | eneajaho | @@ -59,53 +86,82 @@ export function computedFrom<Input extends object, Output = Input>(
* }
* ```
*/
-export function computedFrom(
- sources: any,
- operator?: OperatorFunction<any, any>,
- injector?: Injector
-): Signal<any> {
+export function computedFrom<Input = any, Output = Input>(
+ ...args: any[]
+): Sign... | ```suggestion
throw new TypeError('computedFrom needs pipeable operator as a second argument');
``` |
ngxtension-platform | github_2023 | others | 122 | ngxtension | eneajaho | @@ -84,31 +86,46 @@ setTimeout(() => {
// You can copy the above example inside an Angular constructor and see the result in the console.
```
-The console log will be:
+This will _throw an error_ because the operation pipeline used will produce an observable that will **not have a sync value** because they emit lat... | ```suggestion
This will _throw an error_ because the operation pipeline will produce an observable that will **not have a sync value** because they emit their values later on, so the resulting `c` signal doesn't have an initial value, and this causes the error.
``` |
ngxtension-platform | github_2023 | others | 122 | ngxtension | eneajaho | @@ -84,31 +86,46 @@ setTimeout(() => {
// You can copy the above example inside an Angular constructor and see the result in the console.
```
-The console log will be:
+This will _throw an error_ because the operation pipeline used will produce an observable that will **not have a sync value** because they emit lat... | ```suggestion
This works, and you can copy the above example inside a component constructor and see the result in the console:
``` |
ngxtension-platform | github_2023 | others | 122 | ngxtension | eneajaho | @@ -84,31 +86,46 @@ setTimeout(() => {
// You can copy the above example inside an Angular constructor and see the result in the console.
```
-The console log will be:
+This will _throw an error_ because the operation pipeline used will produce an observable that will **not have a sync value** because they emit lat... | ```suggestion
Another way to solve this problem is using the `startWith` rxjs operator in the pipe to force the observable to have a starting value like below.
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.