A use case for that can be listening to getToken event and then automatically add the new generated token. something like:
var api = new API();
api.$on($scope, '/auth/token', function (token) {
api.setToken(token);
});
api.getToken().then(function (data) {
...
api.$broadcast('/auth/token', data.token);
...
}, function (err) { ... });
Moreover, attaching the path attribute to the method in order to create one source of truth (the swagger spec) for the events mechanism (no need to dig in the implementation to check the path and to change it manually when changed in the spec).
In the method template it will look like this:
var api = new API();
api.$on($scope, api.getToken.path, function (token) {
api.setToken(token);
});
api.getToken().then(function (data) {
...
api.$broadcast(api.getToken.path, data.token);
...
}, function (err) { ... });
A use case for that can be listening to getToken event and then automatically add the new generated token. something like:
Moreover, attaching the path attribute to the method in order to create one source of truth (the swagger spec) for the events mechanism (no need to dig in the implementation to check the path and to change it manually when changed in the spec). In the method template it will look like this:
And the above example will be like this:
What do you think ? sound reasonable ?
Boris :)