angular-http-auth icon indicating copy to clipboard operation
angular-http-auth copied to clipboard

Suggestion: Allow loginConfirmed and loginCancelled from broadcasted event

Open christianrondeau opened this issue 11 years ago • 9 comments

It's a breaking change but one I would personally love :)

Instead of referencing authService, you could provide the loginConfirmed and loginCancelled callbacks directly on the event arguments of the broadcast. That would remove a dependency. Example:

$rootScope.$on('event:auth-loginRequired', function (args) {
    signin().then(
        function() {
            args.loginConfirmed();
        },
        function() {
            args.loginCancelled();
        });
});

Let me know if you'd like me to suggest a pull request!

christianrondeau avatar Feb 14 '14 01:02 christianrondeau

+1

jameskleeh avatar May 05 '14 12:05 jameskleeh

This looks nice, I wish I did not consider it earlier. But now, what can I do? Should I break the API compatibility and force every one to update theirs code? Maybe once AngularJS 2.0 arrives, the new version of this module could apply this pattern, I like it.

witoldsz avatar May 05 '14 12:05 witoldsz

Introducing a new major version doesn't force others to update to it

jameskleeh avatar May 05 '14 13:05 jameskleeh

Yes, but I don't feel this one little convenience is enough to release a new major version.

witoldsz avatar May 05 '14 15:05 witoldsz

I can still provide a pull request if you are interested in releasing a new version.

Another approach would be to create a second event; it bloats the code but won't break existing implementations.

What do you think?

christianrondeau avatar May 06 '14 02:05 christianrondeau

Pull request does not hurt :) You can open one, I won't pull it now, but I will keep an eye on it, so when new major version would be prepared, I could merge it.

witoldsz avatar May 06 '14 08:05 witoldsz

With the breaking change or the new event? Even though I prefer the breaking change, it's up to you.

christianrondeau avatar May 07 '14 11:05 christianrondeau

Braking change I guess, no need to keep them both...

witoldsz avatar May 07 '14 11:05 witoldsz

I just made available a pull request for this (#70). I think it needs a peer review, otherwise feel free to pull if you're happy with it!

christianrondeau avatar Jun 04 '14 01:06 christianrondeau