Git Product home page Git Product logo

Comments (3)

marbemac avatar marbemac commented on May 18, 2024

@christianalfoni Another option to enable this use case, which is kind of interesting, is to pass arguments down if nothing is returned in the action. So:

cerebral.signal('login', session.loading, session.create, session.set)
function login() {
    // this payload needs to be sent through the loading action
    this.signals.login({email: 'foo', password: 'bar'})
}
// no return, so any arguments that were passed into this, get forwarded onto the next signal
let loading = function (cerebral) {
  cerebral.set(['session', '$loading'], true)
}

// payload is passed through to this action
let create = function (cerebral, payload) { 
  // this is an async function
  return Remote.create(Remote.models.SESSION, payload, false)
}

let set = function (cerebral, result) {
  if (result.data) {
    localStorage.session = JSON.stringify(result.data)
    cerebral.set('session', result.data)
  } else {
    cerebral.set('session', {
      $loading: false,
      $error: result.error
    })
  }

  return result.data
}

export default {
  loading: loading,
  create: create,
  set: set
}

from cerebral.

christianalfoni avatar christianalfoni commented on May 18, 2024

Did our hangout session answer these questions? :-) Maybe take a look at next arg-set, return path etc. implementation and move from there?

from cerebral.

christianalfoni avatar christianalfoni commented on May 18, 2024

Just closing this, I think we talked about it ;-)

from cerebral.

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.