Giter VIP home page Giter VIP logo

Comments (5)

cbchouinard avatar cbchouinard commented on July 27, 2024

Would this require a kind of deferred object?

from flowerflip.

bergie avatar bergie commented on July 27, 2024

I think it is generally safer to do composites with components. This way you have a more expressive way to tell what you want to happen, e.g. maybe, some, all

from flowerflip.

cbchouinard avatar cbchouinard commented on July 27, 2024

I agree with @d4tocchini. This could be a way to divide complexe design system and I think we'll have situation where there's only one subtree to execute so its not really a composite.

Furthermore, this a little bit confusing because the following actually works:

   t = Root()
    t.deliver 10
    .then 'then0', (c, d) ->
      d * 2
    .then 'then12', (c, d) ->
        sub = c.continue 'subtree_c'
        sub.deliver d
        sub.then 'subthen0', (c, d) ->
          d / 2
        .then 'subthen1', (c, d) ->
          d * 4
        .else 'subelse', (c, d) ->
          d
    .then 'then1', (c, d) ->
      d * 2
    .else 'else1', (c, d) ->
      d * 4
    .finally (c, d) ->
      chai.expect(d).to.eql 80
      done()

Throwing an error also works.

t = Root()
    t.deliver 10
    .then 'then0', (c, d) ->
      d * 2
    .then 'then12', (c, d) ->
        sub = c.continue 'subtree_c'
        sub.deliver d
        sub.then 'subthen0', (c, d) ->
          d / 2
        .then 'subthen1', (c, d) ->
          throw new Error 'dont feel like doing it'
        .else 'subelse', (c, d) ->
          throw new Error 'me neither'
    .then 'then1', (c, d) ->
      d * 2
    .else 'else1', (c, d) ->
      80
    .finally (c, d) ->
      chai.expect(d).to.eql 80
      done()

Its only when aborting a choice that it gets lost :)

from flowerflip.

d4tocchini avatar d4tocchini commented on July 27, 2024

@bergie, we can run components from a then, the issue is really just a side-effect of abort bubbling too far up, we shouldn't plan our API around that

from flowerflip.

bergie avatar bergie commented on July 27, 2024

Aborts work better now, so closing

from flowerflip.

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.