stretchr / sdk-js

HTML5 and JavaScript SDK for Stretchr
http://docs.stretchr.com/sdks/javascript.md
3 stars 0 forks source link

Is the `new` method OK? #23

Open matryer opened 10 years ago

matryer commented 10 years ago

Since new is a JavaScript keyword, will having it as a method name be a problem?

If so, what should we call it?

see https://github.com/stretchr/sdk-js/blob/rewrite/src/stretchr.js#L249

matryer commented 10 years ago

... I guess the real question is; do the tests pass on all major browsers?

mazondo commented 10 years ago

How is it different than create? Is it meant to let you build a resource locally before saving it?

matryer commented 10 years ago

Exactly.

var ryan = stretchr.new("people", {name: Ryan}).save({
  success: function(){
    alert("Ryan was created with ID " + ryan.id());
  }
});
mazondo commented 10 years ago

hmmmm, yeah I can see why you asked the question then, it's the same thing as new Object() but goes against convention.

Would be nice if we could think of a nice way to do new stretchr.Resource(); to keep it consistent with js.

matryer commented 10 years ago

technically it doesn't go against conventions... lots of methods return a new object. Although I do like the new stretchr.Resource("path", data) idea... I wonder how it would work.

mazondo commented 10 years ago

Typically if you're gong to create a new object you use extend though, how's this for picking up an old conversation with no context. I don't think the sdk supports new now does it?

matryer commented 10 years ago

It does

matryer commented 10 years ago
var ryan = stretchr.new("people", {name: Ryan}).save({
  success: function(){
    alert("Ryan was created with ID " + ryan.id());
  }
});
mazondo commented 10 years ago

oh...hmmm, yeah I would never use that, so I'm not the audience for it. hard to say

matryer commented 10 years ago

So how would you create a new resource?

matryer commented 10 years ago

new stretchr.Resource("path", data) is nice but not implemented right now.

mazondo commented 10 years ago

I'd probably expect it to be new stretchr.Resource I think, but the other way looks good too, just not as conventional I don't think.