by victorNicollet · 9y ago · 0 comments
> user.login({ login: 'user', password: 'secret'});
> const isUserLoggedIn = user.isLoggedIn();
If you look at this purely from an API design point of view, this stinks: by forcing the command to return void, the code ends up twisting its design to return the result of the command through an artificial channel (the state of the 'user' object). In the end, we are still interested in "the result of the login attempt", and the easiest way to do this would be a function that returns a value:
> const isUserLoggedIn = user.login({ login: 'user', password: 'secret' });