Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8876161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:08:38+00:00 2026-06-14T19:08:38+00:00

I’m trying to build an application in ExtJs/Javascript and noticed events are good way

  • 0

I’m trying to build an application in ExtJs/Javascript and noticed events are good way to keep component independent to each others. However, the way events are raised and captured makes them a bit more specific to caller and receiver.

Is there any better way to do this. I’m planning to write one center EventBus class using which any component can raise one event and another can register to listen to it.

Is there any library already available to achieve something like this. I saw backbone.js not sure it’s doing same thing what i’m looking.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:08:40+00:00Added an answer on June 14, 2026 at 7:08 pm

    Writing a Mediator is dead-simple, if you’ve already got a framework that does event-delegation, using a publisher/subscriber or observer model (whether they’re called events or actions or they call the system an emitter or whatever).

    You just make the Mediator the only emitter/publisher/etc, and then give your modules/classes/services/etc access to that Mediator.

    var myEvents = Mediator(),
    
    Module1 = (function (events) {
        var private_data = {},
            private_method = function () {},
            public_interface = { init : init };
    
        function init () { // setup procedures
            events.listen("widget/process/request", function (data) {
                var result = doStuff(data);
                events.fire("widget/process/result", result);
            });
        }
    }(myEvents)),
    
    Module2 = (function (events) {
        var private_data = {},
            public_interface = { init : init };
    
        function init (data) { // setup procedures
            events.fire("widget/process/request", data);
            events.listen("widget/process/result", private_method);
        }
    
        return public_interface;
    }(myEvents));
    
    
    Module1.init();
    Module2.init(data);
    

    If you’d like, you could even do something inside of your classes, to wrap your mediator, so that you can have public methods for your “class” / module, which will look like their own events, but will be passing data through to the mediator:

    var myClass = function () {
        var mediator = null,
            public_interface = {
            fire : function (evt, data) { if (!mediator) { return; } mediator.fire(evt, data); },
            listen : function (evt, handler) { if (!mediator) { return; } mediator.listen(evt, handler); },
            setMediator : function (newMediator) { mediator = newMediator; }
        }
    };
    
    var mediator = Mediator(),
        obj1 = myClass(),
        obj2 = myClass();
    
    obj1.setMediator(mediator);
    obj2.setMediator(mediator);
    
    obj1.listen("event1", obj1.doStuff.bind(obj1));
    obj2.fire("event1", obj2.data);
    

    Your modules now all have access to one single mediator or however many mediators you choose… …you could give each widget its own mediator, which its individual components could share… …plus give each widget access to a system-wide mediator, so while components can’t access global-services like AJAX or the DOM, the widget itself can.

    And by providing an interface in your components, you could program neatly (in a more classical way in your main process, rather than in the lambda/callback-heavy JS way), using public wrapper calls, so now:

    var imageLoader = ImageLoader();
    imageLoader.setMediator(mediator);
    img = imageLoader.load("myimg037");
    imageLoader.fire("imageloader/imageloaded/myimg037", img);
    

    Or however something similar might look in your project — imageLoader knows nothing about any other modules, but when you call its .fire method, any modules sharing the same mediator, and listening for that event will be notified.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to render a haml file in a javascript response like so:
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.