GithubHelp home page GithubHelp logo

Comments (9)

JamesHenry avatar JamesHenry commented on June 10, 2024 1

In my example I am wrapping a Promise?

 protected slowAction$ = defer(() => from(YOUR_PROMISE_HERE));

from angular-eslint.

json-derulo avatar json-derulo commented on June 10, 2024

Why are you using a function which returns the Observable, instead of working with the Observable directly? With your pattern, for each change detection cycle, a new Observable will be created. Sounds like an antipattern to me.

from angular-eslint.

maxfriedmann avatar maxfriedmann commented on June 10, 2024

I changed the example above and added parts of the directive's implementation. Its a function returning a function that returns an Observable/Promise. The function only gets called when clicking on the host element (<my-custom-component/>). That's the reason why I chose this weird construct.

from angular-eslint.

JamesHenry avatar JamesHenry commented on June 10, 2024

@maxfriedmann it might be helpful if you could share a minimal end to end example in a stackblitz?

from angular-eslint.

maxfriedmann avatar maxfriedmann commented on June 10, 2024

@JamesHenry sure: https://stackblitz.com/edit/angular-kxrwgv

from angular-eslint.

JamesHenry avatar JamesHenry commented on June 10, 2024

@maxfriedmann I think using an Observable using rxjs's defer would be preferable here:

https://stackblitz.com/edit/angular-rju8dt?file=src%2Fmain.ts

from angular-eslint.

maxfriedmann avatar maxfriedmann commented on June 10, 2024

Thank you for taking the time. You're right, unfortunately this would require a massive migration in our source (around ~2300 places where [loadingFn] is currently used).

And, more important, that would not work with promises.

from angular-eslint.

maxfriedmann avatar maxfriedmann commented on June 10, 2024

Okay, I'll give this a try. Thank you for your time!

from angular-eslint.

JamesHenry avatar JamesHenry commented on June 10, 2024

Cool hope that's useful! For changes that don't make sense for everyone that uses angular-eslint, it's always possible to build your own lint rules using @angular-eslint/utils so that it also something you can explore if you want to enforce particular unique usage

from angular-eslint.

Related Issues (20)

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.