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

Allow to configure timeout duration by a provider #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions js/postman.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,20 @@
if($rootElement[0].tagName !== 'HTML') $rootElement.append($elem);
else angular.element(document.body).append($elem);
}])

.directive('postmanParcels', ['$timeout', function ($timeout) {
.provider('postmanSettings', function() {
Copy link
Owner

Choose a reason for hiding this comment

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

Does this make it postmanSettingsProvider in the config? Can you not name it the same as the factory and then just access it via name + Provider?

Copy link
Author

Choose a reason for hiding this comment

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

I tried to name it "postman" but postmanProvider is undefined when I use it in the config. I guess it's a conflict with the factory.

var timeout = 6000;
return {
setTimeout : function (value) {
timeout = value;
},
$get : function () {
return {
timeout : timeout
};
}
};
})
.directive('postmanParcels', ['$timeout', 'postmanSettings', function ($timeout, postmanSettings) {
return {
restrict: 'EA',
template: '' +
Expand Down Expand Up @@ -55,7 +67,7 @@
scope.startTimer = function(parcel) {
parcel.timeout = $timeout(function() {
scope.dismiss(parcel, false);
}, 6000);
}, postmanSettings.timeout);
};

// start timer on new item added
Expand Down Expand Up @@ -108,4 +120,4 @@
}
};
}]);
})();
})();