adambeynon changed the topic of #opal to: http://opalrb.org - Ruby runtime and library on top of Javascript | 1.0.0 is near | This channel is logged at http://irclog.whitequark.org/opal
DrShoggoth has joined #opal
marcandre has quit [Remote host closed the connection]
meh` has joined #opal
meh` has quit [Ping timeout: 240 seconds]
meh` has joined #opal
elia has joined #opal
meh` has quit [Ping timeout: 272 seconds]
meh` has joined #opal
<meh`> adambeynon, ping
marcandre has joined #opal
elia has quit [Quit: Computer has gone to sleep.]
<adambeynon> meh`: hi
<meh`> adambeynon, anything against having an implementation of Promise/A in the stdlib?
<meh`> just had to go through callback hell
<meh`> and having a promise implementation in the stdlib will ensure people do use it
<adambeynon> meh`: been looking into something similar to use
<meh`> well, it'll be done by tonight
<meh`> and implemented in opal-browser and lissio
<adambeynon> Rubinius-x was going to adopt some promises lib iirc
<adambeynon> Think I read that anyway
<meh`> adambeynon, those are another kind of promises
<meh`> the sane ones
<meh`> but this is javascript
<meh`> so it has the retarded ones
<meh`> there are promises in my ruby-thread gem
<meh`> the sane ones
<adambeynon> meh`: ah right. Not sure they should be on stdlib though..
<meh`> adambeynon, trust me, they should
<meh`> it's part of commonjs
<meh`> and having it in the stdlib will ensure people do use it
<meh`> it makes things a lot saner
<meh`> and I'd rather not start having a thousand different promise implementations like in js
<meh`> and it's a pain in the ass to have them work together
marcandre has quit [Remote host closed the connection]
lectrick has quit [Ping timeout: 252 seconds]
adambeynon has quit [Ping timeout: 252 seconds]
lectrick has joined #opal
adambeynon has joined #opal
<meh`> adambeynon, do we have define_singleton_method?
<adambeynon> meh`: yes. Not working for you?
<meh`> adambeynon, no, just wondering if I could use it
<meh`> this shit is hard
<meh`> or well, trying to define an API I like
adambeynon has quit [Ping timeout: 240 seconds]
adambeynon has joined #opal
elia has joined #opal
adambeynon has quit [Ping timeout: 260 seconds]
denysonique has quit [Ping timeout: 252 seconds]
lacrosse has quit [Ping timeout: 240 seconds]
lacrosse has joined #opal
adambeynon has joined #opal
denysonique has joined #opal
<meh`> elia, ping
elia has quit [Quit: Computer has gone to sleep.]
<adambeynon> dont think he wanted to pong ;)
<meh`> lol
<meh`> if I manage to make this
<meh`> lissio will become way cooler
<meh`> waaaay cooler
<adambeynon> what you upto?
<meh`> promises
<meh`> and as I go rewriting my app with the promises the more I'm convinced it should be in the stdlib
<meh`> and be STRONGLY promoted for asynchronous things
<adambeynon> meh`: have you got a gist of the impl?
<meh`> adambeynon, still working on it
<meh`> nothing working yet
<meh`> just writing down the API
<meh`> based on how I'm changing my real world code
<adambeynon> are you going to keep strictly to Promises/A spec?
<meh`> no
<meh`> it would be pointless
<meh`> I'm making it rubyesque
<meh`> but the core concept and functionality is there
<meh`> it just has a different API
<meh`> that makes sense in Ruby
<adambeynon> yes, agreed on that
<meh`> http://sprunge.us/NVdL simple stupid example from lissio
<meh`> to actually create a promise
<meh`> any adapter operations return promises
<meh`> instead of accepting a block
<meh`> since models can have remote models as properties
<meh`> let's say you have a Person with a `property :job, as: Job`
<meh`> you can do person.job.do { |job| do things with the actual job model }
<meh`> or person.job.do { |_| }.rescue { |error| unemployed much? }
<meh`> I'm also adding #and and #collect
<meh`> #and takes the result of the previous #do promise
<meh`> this is especially important in case of a model with multiple remote model properties
<meh`> you can do various #and's
<meh`> and then a #collect
<meh`> which calls the block with all the results at each step of the chain
<meh`> this API makes my code 1/3 of the original and waaaaay more readable
<meh`> this stuff is getting really good
elia has joined #opal
<elia> meh`, here I am, wassup?
<meh`> elia, I'm implementing promises
<meh`> and lissio adapters will use promises
<elia> k, should I read the transcript?
<meh`> yeah
<elia> meh`, k, +1 for having them in stdlib, I'll need to read something more about them
<adambeynon> meh`: my only though it to keep the same method name as the js spec
<adambeynon> #then instead of #do
<meh`> adambeynon, #then doesn't work very well
<meh`> I tried
<meh`> adambeynon, especially when #then doesn't accept an error handler
<meh`> #do is only for success
<adambeynon> isnt that the same as the js spec?
<adambeynon> (its been a while since I looked at it..)
<adambeynon> meh`: I was imagining something like:
<meh`> else doesn't sound good there
<meh`> but we can add some aliases
<adambeynon> sorry, should have been #fail
<adambeynon> I always think of the #fail part as an #else part
<adambeynon> also, perhaps a good reference point: https://github.com/jclem/q-defer
<meh`> I don't like it at all
<adambeynon> so whats different with your impl?
elia has quit [Read error: Connection reset by peer]
<meh`> it's more conformant with the Promise/A thing
<meh`> but you'll see when it's done
<meh`> it's all in my head for now
<meh`> I can't explain it without code
<adambeynon> I do think its a good idea to have 2 methods: #do/#then and #fail/#else, rather than the js approach of #then(success, failure)
elia has joined #opal
<elia> meh`, using #do could become ugly for ppl who dislikes curly braces
<elia> adambeynon, and +1 for discarding #then with two callbacks
<meh`> elia, yeah, I'll add two aliases
<meh`> not a problem
<elia> k, see you later, looking forward for the impl #diaperstime
<meh`> lol
<meh`> have fun
elia has quit [Quit: Computer has gone to sleep.]
<meh`> adambeynon, ping
<adambeynon> meh`: yo yo
<meh`> I think I found a bug in opal-repl
<meh`> or something
<meh`> this is saying b is undefined
<adambeynon> undefined, or nil?
<meh`> b is not defined
<meh`> that's the error
<meh`> I'm running it with bin/opal-repl source.rb
<meh`> if I run it with bin/opal it's fine
<adambeynon> Ahh. I know. It's the way it compiles irb local vars
<adambeynon> I'll open an issue to fix it
<meh`> thanks
marcandre has joined #opal
elia has joined #opal