Why use an event bus: allow components to communicate throughout the app in a decoupled way.
This Google Web Toolkit tutorial explains the event bus pattern. Behind the scenes, if you squint your eyes, you can see the subscriber, pub/sub design pattern going on. The purpose and goal of the event bus is to decouple your application, and allow for inter-component communication. Instead, for example, of having some widget take a reference to some other widget, and manually modify that widget when it needs to (perhaps as a result of some user interaction), we could instead use the GWTEvent class to fire or broadcast an event saying that said user interaction has taken place somewhere. Then, any widgets, components, modules, views, presenters, etc., that would like to take action as a result, will be notified about it, and will be allowed to do their thing.
The example in the tutorial users a button, whose click handler fires the event (a Decline event). There is a label widget that wants to know when the button is clicked, so it registers a Decline handler with the event bus. Whenever that event is fired, the label can update itself, according to the business logic that it follows.
The steps to using an event bus are simple:
#1. Create an event - some class that extends GwtEvent, and is typed with the event handler associated with it. Unfortunately, there are some boilerplate code in this class that is tedious, but is not a big deal.
#2. Create an event handler - some interface that extends EventHandler. Here you can define the methods that a handler for the event can/must implement.
#3 Instantiate an event bus - either create your own event bus by extending Event, or use one of the ready, out of the box kinds. Using SimpleEventBus is fine for most cases.
#4 Pass the event bus object around so anyone can register events on it, as well as tell it to fire events as they occur.
Programming tutorials by Easy Learn Tutorial - because anyone can learn how to become an expert software and web developer!
Copyright (c) 2013 Rodrigo Silveira - http://www.easylearntutorial.com
gwtech Event Bus: GWT Tutorial (Google Web Toolkit) | |
| 114 Likes | 114 Dislikes |
| 14,328 views views | 18.1K followers |
| Education | Upload TimePublished on 13 Feb 2014 |
Related keywords
game development courses,javascript tutorial for beginners udemy,javascript tutorial for beginners ppt,programming tutorial free,gwtool gmod,object oriented javascript es6,gwtool,getnet,programming tutorial app,programming tutorial python,php str_replace,game development salary,php for loop,php tutorials for beginners pdf,php strpos,object oriented javascript interview questions,php currency,php in_array,object oriented javascript es6 pdf,programming tutorials java,javascript for,game development course,javascript reduce,object oriented javascript tutorial pdf,php tutorials for beginners with examples,php agency,php foreach,game development jobs,gwtr direto,javascript tutorial for beginners ej media,programming tutorial philippines,javascript для детей,game development books,game development company,getussp,game development life cycle,php tutorials for web development,game development process,programming tutorials online,php date,programming tutorial in lagos,javascript tutorial for beginners to advanced,object oriented javascript w3schools,javascript switch,object oriented javascript projects,object oriented javascript udemy,game development software,php to usd,gwti,game development คือ,programming tutorial hell,gwtk,php tutorials w3schools,programming tutorial javascript,programming tutorial in hindi,php tutorials online,gwtr,programming tutorial pdf,php array length,programming tutorial c++,javascript tutorial for beginners youtube,game development blog,javascript tutorial for beginners 2019,javascript substring,php tutorials point full pdf,php tutorials pdf,javascript книги,programming tutorial c++ pdf,object oriented javascript udacity,object oriented javascript vs functional,php tutorialspoint,javascript tutorial for beginners telusko,php tutorials best,programming tutorial sites,game development reddit,javascript tutorial for beginners in hindi,object oriented javascript frameworks,object oriented javascript book,game development girl ซับไทย,php tutorials youtube,game development girl,gwt board game,php try catch,programming tutorials in telugu,php tutorials for beginners,getty,javascript class,object oriented javascript concepts,game development stages,javascript tutorial for beginners pdf,programming tutorial websites,programming tutorial website templates,php code,php substr,object oriented javascript tutorial point,javascript tutorial for beginners javatpoint,javascript array,javascript tutorial for beginners pdf free download,nintendo web framework tutorial,javascript tutorial for beginners w3schools,javascript map,javascript tutorial for beginners with examples in hindi,game development tools,gwt brasil,php tutorials pdf free download,object oriented javascript tutorial,gwtools,object oriented javascript by stoyan stefanov,javascript foreach,object oriented javascript sample projects,gwt global,javascript settimeout,javascript tutorial for beginners step by step pdf,javascript date,php implode,php tutorials download,php tutorials point pdf,javascript для дітей,nintendo web framework switch,object oriented javascript interview questions and answers,javascript tutorial for beginners in urdu,programming tutorials reddit,gwt showcase,gwt java,php tutorialspoint quick guide,javascript tutorial for beginners in tamil,game development languages,phpstorm,gwtk rh,php explode,javascript tutorial for beginners edureka,php tutorialspoint pdf free download,javascript split,php tutorials javatpoint,phpmyadmin,game development colleges,javascript tutorial for beginners step by step,javascript это,object oriented javascript 3rd edition,object oriented javascript cheat sheet,nintendo web framework download,game development companies,javascript online,tutorialspoint php,javascript уроки,javascript replace,object oriented javascript medium,javascript tutorial for beginners mosh,phpbb,gato,programming tutorials for beginners,javascript tutorial,javascript tutorial for beginners free,php isset,getulio vargas,programming tutorial pdf download,php tutorials in hindi,gtwr11,javascript це,php tutorials free,game development tutorial,php array,
Không có nhận xét nào:
Đăng nhận xét