-
Notifications
You must be signed in to change notification settings - Fork 3.4k
mdToast: API improvement for $mdToast.show(...)
#833
Comments
@rschmukler - This seems like a reasonable API improvement to
|
@ThomasBurleson and @ahmedshuhel, I am hesitant to overload the API for an $mdToast.show($mdToast.simple('Hello!')); |
@rschmukler and @ThomasBurleson,
|
I am not particularly keen on the |
@rschmukler a "simple" toast should just be |
@ilanbiala the advantage of not doing that is that it keeps Toast consistent with other To @gkalpak's point, I'd be more inclined to provide that style of handling this. Ie. for methods which we define constructors ( Also, keep in mind that you can store those results, in a variable, which could make your code cleaner, if you are using the same toast in multiple places. Eg. module.controller('MyCtrl', function($mdToast, MyService, MyOtherService) {
var self = this;
var loadFailed = $mdToast.simple('Failed to load resources');
MyService.fetch().then(function(resources) {
self.resources = resources;
}, function() {
$mdToast.show(loadFailed);
});
MyOtherService.fetch().then(function(otherResources) {
self.otherResources = otherResources;
}, function() {
$mdToast.show(loadFailed);
}); |
@rschmukler it really isn't intuitive for me to have a Toast notification in a variable. Same for $mdDialog really, but I guess that's something others should weigh in on, too. I would think the API should be something like this (assuming wrapped in a controller with the correct injections):
Maybe the |
You are not keeping the notification in the variable, but rather the configuration (preset) for creating the notification, which makes perfect sense imo. @rschmukler: I agree that overloading the interimElement methods is probably not a good idea, but overloading specific interim elements (such as mdToast, mdDialog etc) should be the way to go. |
For a simple toasts that shows a simple text message. It would be nice to have an api like:
$mdToast.show('Hello!');
rather,
$mdToast.show($mdToast.simple().content('Hello!'));
What do you think? I can help with that.
The text was updated successfully, but these errors were encountered: