These are chat archives for ericelliott/stampit

10th
Jun 2015
Tim Routowicz
@troutowicz
Jun 10 2015 00:01
Ok
Carl Olsen
@unstoppablecarl
Jun 10 2015 11:54
@koresar you around?
@koresar do you think this is better than using bind with the shortcutMethod ? https://gist.github.com/unstoppablecarl/84a8e4c968f68d8b366b
Vasyl Boroviak
@koresar
Jun 10 2015 13:12
AFAIK closures are more expensive than function calls.
Binding is expensive, but it's done once.
You can jsperf both approaches and share the link.
Carl Olsen
@unstoppablecarl
Jun 10 2015 13:14
I dont think it is work perf testing I just thought it was more clear
Just wondering what you thought
Vasyl Boroviak
@koresar
Jun 10 2015 13:15
Yeah, your approach is more readable.
Carl Olsen
@unstoppablecarl
Jun 10 2015 13:15
but if you think it will be slower dont bother
Vasyl Boroviak
@koresar
Jun 10 2015 13:16
I think, but I'm not an expert for sure
Carl Olsen
@unstoppablecarl
Jun 10 2015 13:19
@koresar do you think this is a problem?

var connection = {
    name: 'my connection',
    settings: {
        foo: 'bar'
    }
};
var stamp = stampit()
.refs({
    connection: connection
})
.props({
    connection: {
        name: 'default connection',
        settings: {
            foo: 'foo',
            bam: 'bam'
        }
    }
});

var instance = stamp();
// original connection object was modified
console.log(connection); // 'ref connection'
I think this is somewhat surprising behavior
Vasyl Boroviak
@koresar
Jun 10 2015 13:23
Ok. The (only) PR is time to merge. /cc @ericelliott
What's the console prints?
Carl Olsen
@unstoppablecarl
Jun 10 2015 13:24
{ name: 'my connection', settings: { foo: 'bar', bam: 'bam' } }
it added bam to the original object
Vasyl Boroviak
@koresar
Jun 10 2015 13:25
Yes. It's how I designed it.
Carl Olsen
@unstoppablecarl
Jun 10 2015 13:25
What is a case where you would want that to happen?
Vasyl Boroviak
@koresar
Jun 10 2015 13:26
Add the connection to the stamp() argument. We need the argument to persist in the object instance.
It's all complicated. ☺
Carl Olsen
@unstoppablecarl
Jun 10 2015 13:27
I think the expectation would be that the connection in refs would completely replace the one in props
that is my expectation at least.
Vasyl Boroviak
@koresar
Jun 10 2015 13:28
My expectations is props to be deeply merged.
Carl Olsen
@unstoppablecarl
Jun 10 2015 13:29
I agree with that, but I think the modification of the object by ref is a sideeffect you would not want
Vasyl Boroviak
@koresar
Jun 10 2015 13:30
There dozens of side effects otherwise.
Carl Olsen
@unstoppablecarl
Jun 10 2015 13:30
that is true
Vasyl Boroviak
@koresar
Jun 10 2015 13:31
That's the example where you want that to happen https://github.com/ericelliott/stampit/pull/96#discussion_r32092247
Carl Olsen
@unstoppablecarl
Jun 10 2015 13:33
this is why I think the refs argument in stamp(refs) should not have an assumed behavior and be sent to init()
what are your thoughts on that?
I know it is not a good idea bc it breaks 1.x but I want to know what you think
if there was no 1.x
Vasyl Boroviak
@koresar
Jun 10 2015 13:35
Well, ftom my projects and experience that would increase boilerplate code a lot.
I'm heavily using stamp(refs) API feature.
Carl Olsen
@unstoppablecarl
Jun 10 2015 13:36
and I assume never colliding with props?
Vasyl Boroviak
@koresar
Jun 10 2015 13:36
Exactly.
In real life situations I had no collisions ever.
Carl Olsen
@unstoppablecarl
Jun 10 2015 13:36
never replaced anything?
Vasyl Boroviak
@koresar
Jun 10 2015 13:37
Replaced refs with other refs, but that's it.
Carl Olsen
@unstoppablecarl
Jun 10 2015 13:37
we should probably document that refs and props are not really intended to collide. not sure how best to explain that :-/
:point_up: June 6 2015 1:52 PM do you have an answer to this question?
Vasyl Boroviak
@koresar
Jun 10 2015 13:38
Also, in another project (two actually) I needed stamp() to deeply merge the given argument. So now stampit v2 will serve all purposes. Which I'm very happy of
+1 to explaining that in readme.
No, I have no answers to that. You can browse issues on the github. I asked same or similar questions year ago.
Carl Olsen
@unstoppablecarl
Jun 10 2015 13:40
what have you done in your projects in the past?
just made a comment?
Vasyl Boroviak
@koresar
Jun 10 2015 13:42
Well, my code was changing too fast. I got quickly annoyed updating the relevant JSDoc all the time. So I just dropped it. Readable code is more descriptive than any comments. ☺