Skip to content

Instantly share code, notes, and snippets.

@jots
Created November 13, 2013 19:09
Show Gist options
  • Save jots/7454559 to your computer and use it in GitHub Desktop.
Save jots/7454559 to your computer and use it in GitHub Desktop.
#iced = require('iced-coffee-script').iced
fs = require("fs")
class T
constructor: (cb) ->
console.log "asdf"
await fs.readFile __filename, "utf8", defer(err,res)
cb(err,res)
module.exports = T
T = require "./t.js"
await t = new T defer(err,res)
console.log err
console.log res
@maxtaco
Copy link

maxtaco commented Nov 13, 2013

I generally do not use await/defer in constructors, but I guess your system can work.

I got your example to work as you have it, but I changed line 1 of ta.coffee to T = require './t' --- that is, I dropped the .js suffix.

Which version of ICS do you have? I have 1.6.3-g

@jots
Copy link
Author

jots commented Nov 13, 2013

I am also on IcedCoffeeScript version 1.6.3-g

I dropped the ".js" and still got the same error.

I was trying to think of a way to avoid the callback in the constructor, but haven't yet.
The real code is (the bare beginnings of) a DB framework, and I want to get a list of all the tables and their columns to populate an instance variable. await in the constructor seems to be the way to do it so far.

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