@ngneat/subscribe
Advanced tools
Comparing version 3.0.2 to 4.0.0
@@ -1,2 +0,2 @@ | ||
import { ChangeDetectorRef, OnInit, TemplateRef, ViewContainerRef, OnDestroy } from '@angular/core'; | ||
import { ChangeDetectorRef, OnDestroy, OnInit, TemplateRef, ViewContainerRef } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
@@ -10,4 +10,3 @@ import * as i0 from "@angular/core"; | ||
} | ||
declare type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N; | ||
export declare class SubscribeDirective<T, InitialSyncValue extends boolean = true> implements OnInit, OnDestroy { | ||
export declare class SubscribeDirective<T> implements OnInit, OnDestroy { | ||
private tpl; | ||
@@ -19,18 +18,12 @@ private cdr; | ||
private context; | ||
initialSyncValue: InitialSyncValue; | ||
strategy: 'markForCheck' | 'detectChanges'; | ||
set subscribe(source: Observable<T>); | ||
static ngTemplateContextGuard<T, InitialSyncValue extends boolean = true>(directive: SubscribeDirective<T, InitialSyncValue>, context: unknown): context is SubscribeContext<IfAny<InitialSyncValue, T, T | undefined>>; | ||
constructor(tpl: TemplateRef<any>, cdr: ChangeDetectorRef, vcr: ViewContainerRef); | ||
static ngTemplateContextGuard<T>(directive: SubscribeDirective<T>, context: unknown): context is SubscribeContext<T>; | ||
constructor(tpl: TemplateRef<SubscribeContext<T>>, cdr: ChangeDetectorRef, vcr: ViewContainerRef); | ||
ngOnInit(): void; | ||
ngOnDestroy(): void; | ||
private onChange; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<SubscribeDirective<any, any>, never>; | ||
static ɵdir: i0.ɵɵDirectiveDeclaration<SubscribeDirective<any, any>, "[subscribe]", never, { "initialSyncValue": "initialSyncValue"; "strategy": "strategy"; "subscribe": "subscribe"; }, {}, never>; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<SubscribeDirective<any>, never>; | ||
static ɵdir: i0.ɵɵDirectiveDeclaration<SubscribeDirective<any>, "[subscribe]", never, { "strategy": "strategy"; "subscribe": "subscribe"; }, {}, never, never, true, never>; | ||
} | ||
export declare class SubscribeModule { | ||
static ɵfac: i0.ɵɵFactoryDeclaration<SubscribeModule, never>; | ||
static ɵmod: i0.ɵɵNgModuleDeclaration<SubscribeModule, [typeof SubscribeDirective], never, [typeof SubscribeDirective]>; | ||
static ɵinj: i0.ɵɵInjectorDeclaration<SubscribeModule>; | ||
} | ||
export {}; |
{ | ||
"name": "@ngneat/subscribe", | ||
"description": "Subscription Handling Directive", | ||
"version": "3.0.2", | ||
"version": "4.0.0", | ||
"dependencies": { | ||
@@ -18,2 +18,5 @@ "tslib": "^2.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@angular/core": ">=14.0.0" | ||
}, | ||
"bugs": { | ||
@@ -32,3 +35,3 @@ "url": "https://github.com/ngneat/subscribe/issue" | ||
"fesm2015": "fesm2015/ngneat-subscribe.mjs", | ||
"typings": "ngneat-subscribe.d.ts", | ||
"typings": "index.d.ts", | ||
"exports": { | ||
@@ -39,3 +42,3 @@ "./package.json": { | ||
".": { | ||
"types": "./ngneat-subscribe.d.ts", | ||
"types": "./index.d.ts", | ||
"esm2020": "./esm2020/ngneat-subscribe.mjs", | ||
@@ -42,0 +45,0 @@ "es2020": "./fesm2020/ngneat-subscribe.mjs", |
@@ -1,1 +0,1 @@ | ||
export { SubscribeModule, SubscribeDirective } from './lib/subscribe.directive'; | ||
export { SubscribeDirective } from './lib/subscribe.directive'; |
@@ -12,3 +12,2 @@ [![MIT](https://img.shields.io/packagist/l/doctrine/orm.svg?style=flat-square)]() | ||
## Installation | ||
@@ -18,21 +17,12 @@ | ||
## Usage | ||
First, we need to import the `SubscribeModule`: | ||
Now we can import the `SubscribeDirective` and use the `subscribe` directive in our template: | ||
```ts | ||
import { SubscribeModule } from '@ngneat/subscribe'; | ||
import { SubscribeDirective } from '@ngneat/subscribe'; | ||
@NgModule({ | ||
imports: [SubscribeModule] | ||
}) | ||
class MyModule {} | ||
``` | ||
Now we can use the `subscribe` directive in our template: | ||
```ts | ||
@Component({ | ||
imports: [SubscribeDirective], | ||
template: ` | ||
<ng-container *subscribe="getUsers$; let users; let error=error"> | ||
<ng-container *subscribe="users$ as users; let error=error"> | ||
{{ users | json }} | ||
@@ -44,29 +34,4 @@ {{ error }} | ||
class MyComponent { | ||
getUsers$ = this.service.getUsers(); | ||
constructor(private service: UserService) {} | ||
users$ = inject(UserService).getUsers(); | ||
} | ||
``` | ||
## Contributors ✨ | ||
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): | ||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> | ||
<!-- prettier-ignore-start --> | ||
<!-- markdownlint-disable --> | ||
<table> | ||
<tr> | ||
<td align="center"><a href="https://www.netbasal.com/"><img src="https://avatars.githubusercontent.com/u/6745730?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Netanel Basal</b></sub></a><br /><a href="https://github.com/@ngneat/subscribe/commits?author=NetanelBasal" title="Code">💻</a> <a href="#ideas-NetanelBasal" title="Ideas, Planning, & Feedback">🤔</a></td> | ||
</tr> | ||
</table> | ||
<!-- markdownlint-restore --> | ||
<!-- prettier-ignore-end --> | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! | ||
<div>Icons made by <a href="http://www.freepik.com/" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a></div> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
28229
2
269
35