Giter VIP home page Giter VIP logo

Comments (6)

machty avatar machty commented on May 19, 2024 3

@Luiz-N I'm sorry it's taken me so long to respond.

I suppose that's a good idea given how many people use ember-route-action-helper.

One reason I've hesitated on something like this is that it's already a lot easier to pass tasks around than it is to pass actions around (you can just pass a reference to the task to the controller rather than have to use .bind() or closures or something). But yeah, I'd consider something like this.

(hoping for some other feedback from people who also think it's a good idea)

from ember-concurrency.

buschtoens avatar buschtoens commented on May 19, 2024 2

I've created a quick PoC for a route-task helper here: ember-route-task-helper
You can check out a demo here. The source code for the demo is the tests/dummy app.

Give it a try and feel free to open issues for feedback! :)

from ember-concurrency.

buschtoens avatar buschtoens commented on May 19, 2024 2

In the example shown in the README, I use {{get (route-task "deleteUser") "isIdle"}}, but I dislike this kind of syntax. I recommend using the {{with}} helper:

{{#with (route-task "taskOnApplicationRoute" "Freddie") as |task|}}
  {{#if task.isIdle}}
    <button onclick={{perform task "Morecurry"}}>
      Perform taskOnApplicationRoute
    </button>
  {{else}}
    <button onclick={{cancel-all task}}>
      Cancel taskOnApplicationRoute
    </button>

    Running taskOnApplicationRoute
  {{/if}}

  <br>
  task.last.value: {{task.last.value}}<br>
  task.last.error: {{task.last.error}}<br>
{{/with}}

Or even better, only use {{route-task}} to pass tasks as attributes to components.

{{task-aware-button
  task=(route-task "deleteUser" model)
  idleLabel=(concat "Delete " model.name)
  runningLabel="Cancel deletion"
}}

from ember-concurrency.

mikkopaderes avatar mikkopaderes commented on May 19, 2024

IMO, might be worth the wait to see the RFC for routable components first. In the previous one, I think they were also passing args to the route component similar to setupController. So if we're still headed that way and not like the route-action then at least there wouldn't be any wasted efforts.

from ember-concurrency.

nullrocket avatar nullrocket commented on May 19, 2024

I would really like to see this be a thing.

from ember-concurrency.

webark avatar webark commented on May 19, 2024

it's probably going to bite me down the road. But right now I'm giving this a try.

  setupController() {
    this._super(...arguments);

    this.TASK.taskFn = this.TASK.taskFn.bind(this);
    set(this.controller, 'TASK', this.TASK);
  },

where TASK is the concurrency task.

from ember-concurrency.

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.