Giter Club home page Giter Club logo

Comments (6)

poteto avatar poteto commented on May 17, 2024

It's originally meant to mimic Rails' style flash messages. Is there a reason why you want to have a flash message inside of an Ember.Object? I'm not opposed to creating a mixin, just curious what the use case is

from ember-cli-flash.

AlexCppns avatar AlexCppns commented on May 17, 2024

I am trying to inject it in another service which I am using in my controller. I am new to emberJS so I am not as familiar with the design patterns. Let me know if there is a better way to do it.

from ember-cli-flash.

AlexCppns avatar AlexCppns commented on May 17, 2024

Actually, is it supposed to work with an objectController? I just tried and I am getting an error:

Uncaught TypeError: Cannot read property 'success' of undefined

My code looks like this:

import Ember from 'ember';

export default Ember.ObjectController.extend({
  handleChangeStateCallback: function(update, campaign, flash){
    update.done(function(data) {
      flash.success(data.notice);
      campaign.set('status', data.started);
    })
      .fail(function(xhr, textStatus, errorThrown) {
        alert('start campaign failed');
      });
  },
  actions: {
    deleteCampaign: function(){
      var campaign = this.get('model');
      campaign.deleteRecord();
      campaign.save();
    },
    changeCampaignState: function(action){
      var flash = Ember.get(this, 'flashes');
      var campaign = this.get('model');
      var update = this.agentGatewayService.changeCampaignState(campaign, action);
      this.handleChangeStateCallback(update, campaign, flash);
    }
  }
});

from ember-cli-flash.

gte451f avatar gte451f commented on May 17, 2024

I've found a need to use Flash messages in mixins.
+1 for access within Ember.Object, preferably a manual method. Something like...

import Ember from 'ember';
import Flash from 'ember-cli-flash/mixin/flash';
export default Ember.Mixin.create({
    actions:{
        someAction: function(){
            Flash.success('FLASH me!  Well, not THAT type of FLASH, the other less risqué' meaning of FLASH.  Put your shirt on.');
        }
    }
});

from ember-cli-flash.

poteto avatar poteto commented on May 17, 2024

Alright, I'll put this in the next milestone

from ember-cli-flash.

poteto avatar poteto commented on May 17, 2024

Hey guys, I'm deciding against making a mixin out of the service, as isn't really necessary if your object is registered in the container. You can use Ember.inject.service to get a reference to the service.

from ember-cli-flash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.