Skip to content

Asynchronous init? #9

Description

@ryleyb

How do I deal with the case where I want to do something asynchronously in my model.init function?

For instance:

myModel.init = function(instance){
  exec('ls -l',function(err,stdout,stderr){
    //error checking etc
    instance.files(stdout);
  }
}

So far my solution has been to use a promise as the contents of that particular attribute, but that doesn't seem ideal. Is there a better way?

In my controller, it would be nice if I could do this:

Q.when(myModel.create()).then(.... //etc

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions