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

Feature/identifier #15

Merged
merged 2 commits into from Aug 28, 2016
Merged

Feature/identifier #15

merged 2 commits into from Aug 28, 2016

Conversation

zenangst
Copy link
Contributor

@zenangst zenangst commented Aug 28, 2016

This PR adds a new property to the ViewModel. The new property is called Identifier and is of type Int. This can be used to achieve uniqueness in your view models. It can represent an ID that you get from your backend or it can be a computed String that you assign yourself.

When assigning String, you can do so by passing the hash value for that string.

let item = ViewModel(identifier: "user-34".hashValue)

@@ -93,6 +100,7 @@ public struct ViewModel: Mappable {
*/
public init(_ map: JSONDictionary) {
index <- map.property(.Index)
identifier = map.property(.Identifier)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zenangst Shouldn't it be identifier <- map.property(.Identifier)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compiler threw a bunch of complaints when trying to assign a value to something that is yet to be initialized using that operator.

@vadymmarkov vadymmarkov merged commit e09f56c into master Aug 28, 2016
@vadymmarkov vadymmarkov deleted the feature/identifier branch August 28, 2016 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants