scup / react-entity

[DEPRECATED IN FAVOR OF :octocat: github.com/scup/speck] Define isomorphic entities based on React propTypes
MIT License
22 stars 4 forks source link

Change .fetch to .toJson #3

Open dalssoft opened 8 years ago

albertossilva commented 8 years ago

The return is not a JSON, maybe toObject.

guisouza commented 8 years ago

Its not a JSON because it could have methods ? or because its not a JSON ? toObject sounds weird, since in fact it will be anObject.toObject that returns a Object .. It could be .raw, since it will not return the methods. In fact, it returns a transition state of that Entity, something that when passed again to the entity constructor, must reproduces the same state. .getState() .state .raw .data

albertossilva commented 8 years ago

Because it is not a JSON. Raw or data are good as well. State or getState() is not so good because the child classes can have their own state attributes, do you agree?

Should we maintain fetch() for sometime with a warning? On Mar 28, 2016 08:06, "Guilherme (Coder) de Souza" < notifications@github.com> wrote:

Its not a JSON because it could have methods ? or because its not a JSON ? toObject sounds weird, since in fact it will be anObject.toObject that returns a Object .. It could be .raw, since it will not return the methods. In fact, it returns a transition state of that Entity, something that when passed again to the entity constructor, must reproduces the same state. .getState() .state .raw .data

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/scup/react-entity/issues/3#issuecomment-202342109

dalssoft commented 8 years ago

Ideas: serialize / asJson / asRawValue.

user.serialize()

or

user.asJson()

Based on Rails Active Record (a bad pattern but good method names) http://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html