Coder Social home page Coder Social logo

deborahk / angular-rxjs-signals-fundamentals Goto Github PK

View Code? Open in Web Editor NEW
23.0 23.0 69.0 683 KB

Sample code for the Pluralsight course "RxJS and Angular Signal Fundamentals"

Home Page: https://www.pluralsight.com/library/courses/rxjs-angular-signals-fundamentals

License: MIT License

TypeScript 68.24% CSS 1.71% HTML 30.05%
angular rxjs signals

angular-rxjs-signals-fundamentals's Introduction

angular-rxjs-signals-fundamentals's People

Contributors

deborahk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

angular-rxjs-signals-fundamentals's Issues

The InMemory Data Serive is missing the Service decorator

Within the AppData, it is missing the Service/Injectable decorator which is failing to Inject when fetching the data resulting in a 404.

Expected

@Injectable({
  providedIn: 'root',
})
export class AppData implements InMemoryDbService {

Using toSignal in a root-provided service can lead to memory leaks?

According to @NetanelBasal toSignal uses the injectorโ€™s context for unsubscription by default. When used in a root service, this can lead to memory leaks when the consuming component is destroyed. More on that you can read here: https://netbasal.com/navigating-the-nuances-of-tosignal-in-angular-what-to-know-e4d6a4b5dfaf

Your code, for example the ProductService root service, also uses this potentially dangerous pattern:

// apm-final/src/app/products/product.service.ts
@Injectable({
  providedIn: 'root'
})
export class ProductService {
  private productsResult = toSignal(this.productsResult$,
    { initialValue: ({ data: [] } as Result<Product[]>) });

  products = computed(() => this.productsResult().data);
  productsError = computed(() => this.productsResult().error);
}
// apm-final/src/app/products/product-list/product-list.component.ts
export class ProductListComponent {
  private productService = inject(ProductService);

  // Products
  products = this.productService.products;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.