Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the new method OK? #23

Open
matryer opened this issue Sep 30, 2013 · 12 comments
Open

Is the new method OK? #23

matryer opened this issue Sep 30, 2013 · 12 comments
Assignees
Labels

Comments

@matryer
Copy link
Member

matryer commented Sep 30, 2013

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

@ghost ghost assigned mazondo Sep 30, 2013
@matryer
Copy link
Member Author

matryer commented Sep 30, 2013

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

@mazondo
Copy link
Contributor

mazondo commented Sep 30, 2013

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

@matryer
Copy link
Member Author

matryer commented Sep 30, 2013

Exactly.

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

@mazondo
Copy link
Contributor

mazondo commented Sep 30, 2013

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
Copy link
Member Author

matryer commented Sep 30, 2013

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
Copy link
Contributor

mazondo commented Jan 31, 2014

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
Copy link
Member Author

matryer commented Jan 31, 2014

It does

@matryer
Copy link
Member Author

matryer commented Jan 31, 2014

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

@mazondo
Copy link
Contributor

mazondo commented Jan 31, 2014

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

@matryer
Copy link
Member Author

matryer commented Jan 31, 2014

So how would you create a new resource?

@matryer
Copy link
Member Author

matryer commented Jan 31, 2014

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

@mazondo
Copy link
Contributor

mazondo commented Jan 31, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants