Skip to content

Commit

Permalink
Improve documentation a little bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Oleś committed Jun 24, 2017
1 parent a3ce1ca commit d153f52
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,27 @@ const user = new User({
userName: 'piotr',
permissions: Set([Permission.DEVELOPER])
});

user.getUserName(); // > piotr
user.hasPermission(Permission.ADMIN); // false
user.isAdmin(); // false


// we create adminUser based on user - immutable data
// create admin user based on user - immutable data
const adminUser = user.addPermission(Permission.ADMIN); // make me an admin!

adminUser.getUserName(); // > piotr
adminUser.hasPermission(Permission.ADMIN); // > true
user.hasPermission(Permission.ADMIN); // false
adminUser.isAdmin(); // > true
user.isAdmin(); // > false


// create another user
const anotherUser = new User({
userName: 'lukasz',
createdBy: adminUser
});

anotherUser.isAdmin(); // > false
anotherUser.isCreatedByAdmin(); // > true
```
Like you see, `User` class hides complexity of Immutable.js structures and contains business logic.

Expand Down

0 comments on commit d153f52

Please sign in to comment.