EventBus is an Android optimized publish/subscribe event bus. A typical use case for Android apps is gluing Activities, Fragments, and background threads together.
Alex Manoel Coelho1, Wesley Bezerra2
1Aluno 7ª fase do Curso de Ciência da Computação do Instituto Federal Catarinense - Campus Rio do Sul
2Professor de Ensino Superior do Instituto Federal Catarinense - Campus Rio do Sul
Alex Manoel Coelho1, Wesley Bezerra2
1Aluno 7ª fase do Curso de Ciência da Computação do Instituto Federal Catarinense - Campus Rio do Sul
2Professor de Ensino Superior do Instituto Federal Catarinense - Campus Rio do Sul
O presente slide tem por objetivo fazer com que os alunos reflitam sobre a Consciência Negra, através de falas dos próprios negros de vários segmentos da sociedade, desde um estudante até uma designe de moda. Assim, eles procuraram criar a sua própria ideia da importância do dia e se essa comemoração deveria ser realizada em todos os dias do ano. Os alunos refletiram. A atividade foi aplicada na E.E.E.M.P Dr. Elpídio de Almeida – Estadual da Prata, na turma do 3° ano Comercio do turno da manhã, no dia 30 de Novembro de 2016.
Recomendar, relacionar, encontrar. Os bancos de dados em grafos são cada vez mais utilizados em sistemas onde relacionamentos tem alto valor de negócio.
Mas você sabe como utilizar eles?
Aprenda os conceitos básicos nesta apresentação.
O fenômeno do envelhecimento populacional tem impacto significativo sobre diversas dimensões do desenvolvimento e do funcionamento das sociedades bem como sobre o bemestar relativo não só dos idosos como das populações mais jovens. Dessas dimensões, as mais importantes são os sistemas de aposentadoria e pensões, a composição dos padrões de participação na força de trabalho, as disposições de caráter familiar e domiciliar, as transferências intrafamiliares entre gerações e as condições de saúde dos mais velhos.
Neste resumo do primeiro modelo discute-se os pressupostos defendidos por Naturalismo e pelo Construção social, conceitos chaves da sexualidade, percurso da Sexualidade na Antropologia, noções de feminilidade e masculinidade na sexualidade, e Corpo como constructo social.
Melhor e maior conteudo da antropologia so no blog: http://soantropologia.blogspot.com/
We now know that we have an Event system in place in Drupal 8 which has been imported from Symfony, the Symfony Event Dispatcher Component. The Event system will likely replace the traditional hook system altogether in coming drupal versions. This talk will try to throw some light on how to create, trigger, subscribe and listen to events in drupal 8.
This session will mainly elustrate:
What are Events. Why do we need to trigger events?
What all do we need Events for and where we are still stuck with hooks.
Events in Drupal 8
Symfony Event Dispatcher component
When to fire an event.
When to expose your hook in Drupal 8? Never.
How to create and dispatch an Event from your module.
How to listen or subscribe to an Event from your custom Event or an event from core.
How are event listeners and event subscribers different.
Different types of Event dispatchers.
Examples where events have been exhaustively used.
A simple demo implementation of events.
Attendees should be familiar with:
Basic Drupal 8 module development.
Basic OOP principles and practices.
Symfony components used in D8.
After attending this session attendees will be able to:
Create their custom events in Drupal 8
Subscribe to the events from core and other modules and to their custom events too.
Will have a knowledge of where to explore the events and where we have to still use hooks.
JavaScript Browser Events are an essential part of web development, allowing developers to create dynamic, interactive web applications. In this presentation, we will explore the basics of JavaScript Browser Events, including what they are, how they work, and why they are important.
O presente slide tem por objetivo fazer com que os alunos reflitam sobre a Consciência Negra, através de falas dos próprios negros de vários segmentos da sociedade, desde um estudante até uma designe de moda. Assim, eles procuraram criar a sua própria ideia da importância do dia e se essa comemoração deveria ser realizada em todos os dias do ano. Os alunos refletiram. A atividade foi aplicada na E.E.E.M.P Dr. Elpídio de Almeida – Estadual da Prata, na turma do 3° ano Comercio do turno da manhã, no dia 30 de Novembro de 2016.
Recomendar, relacionar, encontrar. Os bancos de dados em grafos são cada vez mais utilizados em sistemas onde relacionamentos tem alto valor de negócio.
Mas você sabe como utilizar eles?
Aprenda os conceitos básicos nesta apresentação.
O fenômeno do envelhecimento populacional tem impacto significativo sobre diversas dimensões do desenvolvimento e do funcionamento das sociedades bem como sobre o bemestar relativo não só dos idosos como das populações mais jovens. Dessas dimensões, as mais importantes são os sistemas de aposentadoria e pensões, a composição dos padrões de participação na força de trabalho, as disposições de caráter familiar e domiciliar, as transferências intrafamiliares entre gerações e as condições de saúde dos mais velhos.
Neste resumo do primeiro modelo discute-se os pressupostos defendidos por Naturalismo e pelo Construção social, conceitos chaves da sexualidade, percurso da Sexualidade na Antropologia, noções de feminilidade e masculinidade na sexualidade, e Corpo como constructo social.
Melhor e maior conteudo da antropologia so no blog: http://soantropologia.blogspot.com/
We now know that we have an Event system in place in Drupal 8 which has been imported from Symfony, the Symfony Event Dispatcher Component. The Event system will likely replace the traditional hook system altogether in coming drupal versions. This talk will try to throw some light on how to create, trigger, subscribe and listen to events in drupal 8.
This session will mainly elustrate:
What are Events. Why do we need to trigger events?
What all do we need Events for and where we are still stuck with hooks.
Events in Drupal 8
Symfony Event Dispatcher component
When to fire an event.
When to expose your hook in Drupal 8? Never.
How to create and dispatch an Event from your module.
How to listen or subscribe to an Event from your custom Event or an event from core.
How are event listeners and event subscribers different.
Different types of Event dispatchers.
Examples where events have been exhaustively used.
A simple demo implementation of events.
Attendees should be familiar with:
Basic Drupal 8 module development.
Basic OOP principles and practices.
Symfony components used in D8.
After attending this session attendees will be able to:
Create their custom events in Drupal 8
Subscribe to the events from core and other modules and to their custom events too.
Will have a knowledge of where to explore the events and where we have to still use hooks.
JavaScript Browser Events are an essential part of web development, allowing developers to create dynamic, interactive web applications. In this presentation, we will explore the basics of JavaScript Browser Events, including what they are, how they work, and why they are important.
This talk will explain the Google Web Toolkit (GWT), GWT architecture, and why you would want to use GWT. In addition, it will include a demo of GWT and the recently released GWT Designer (a tool that makes GWT development easy and that makes it fast to generate a complicated UI).
A Series of Fortunate Events - PHP Benelux Conference 2015Matthias Noback
What is an event really? How can you best describe an event in your code? What types of events are there, and how do you decide whether or not to implement something as an event?
In this talk we start with a straightforward command-only piece of code. We extract events from it and start moving the event handling code out, trying different design patterns on the way. First we try Observer. Then we introduce event data, event handlers and a Mediator between our code and the event handlers. Finally we pick a well-known event dispatcher implementation (the Symfony EventDispatcher) and see how it uses the Chain of Responsibility design pattern to control the entire flow of a web application request.
In the end I will answer some burning questions like: is it safe to use events all over the place and rely on event handlers to do some really important stuff? How do I overcome the indirection in my event-driven code? And how can I quickly find out what happens where?
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
5. Status Quo in Android
Activity
Activity
Service / Helper
Fragment Fragment Thread
6. Communication Issues?!
Tight coupling of components
Inflexible, changes are expensive
Boiler plate code
– Define interfaces
– Callbacks for asynch. communication
– Listener management
– Propagation through all layers
7. EventBus Communication
Activity Activity
Event
Bus
Service / Helper
Fragment Fragment Thread
8. EventBus for Android
Event-based Publish/Subscribe
Bus: central communication
Inspired by Guava„s EventBus (Google)
Android-optimized
Open Source, Apache 2 License
https://github.com/greenrobot/EventBus
9. EventBus in 4 Steps
1. Define an event
2. Register subscriber
3. Post an event
4. Receive the event
10. EventBus in 4 Steps: Code!
1. Define an event
public class MyEvent {}
2. Register subscriber
EventBus.getDefault().register(this);
3. Post an event
EventBus.getDefault().post(event);
4. Receive the event
public void onEvent(MyEvent event);
12. EventBus Instances
EventBus instances
Instances are indepent from each other
For many apps, a single instance is fine
„Convenience“ Instance
EventBus.getDefault()
Aquire it anywhere(!) in your code
13. Event Handler Method:
onEvent
EventBus scans subscribers
– During (first) registration of subscriber
– For event handler methods
Event handler methods
– Naming convention: onEvent
– public visibility
– No return value (void)
– Single parameter for the event to receive
14. Type-based Event Routing
Event type: Java class of the event
To receive an event, its type must match
post(new MyEvent());
onEvent(MyEvent event) {…}
Type hierarchy of events
– Implement logging of all events:
onEvent(Object event)
15. Event Type is a Filter
Subscriber
Event
Event Event onEvent(MyEvent)
Publisher
post Bus
(MyEvent)
Subscriber
onEvent(OtherEvent)
18. EventBus Code: Receiver
MyActivity extends Activity // no interf.
// onCreate or onResume
EventBus.getDefault().register(this);
// onDestroy or onPause
EventBus.getDefault().unregister(this);
public onEvent(MyEvent event) { … }
19. Example: Fragment to
Fragment
Tap on one fragment
Another fragment reacts
Typical list/details scenario
Conventional setup: Activity
Activity is managing
Fragments
Fragment Fragment
26. Why do Threads matter?
Responsive UI, Android conventions
– Main/UI thread must not block
– UI updates in the main thread
– Networking etc. in background threads
Threads and Events
– Thread posting events
– Thread handling events
– Posting and handling thread may differ
27. EventBus Threading Support
Event delivery using threads
Event handler method decides
(handler knows best what it is doing)
Naming conventions for onEvent methods
To deliver in the main thread:
onEventMainThread(…)
(All methods beginning with onEvent are
checked for typos)
28. Thread Modes
PostThread: Direct call in same thread
MainThread: UI updates etc.
BackgroundThread: „not the main
thread“
Async: always asynchronous to posting
Used in the method name: onEventXXX
No additional code required
29. Threading Example
Network thread posts result
post(new UserLoginEvent(name));
Fragment reacts to event in main thread
public void
onEventMainThread(UserLoginEvent e) {
textView.setText(e.getName());
}
31. Upcoming: EventBus 2.1
EventBus 2.1 is not final yet;
Still gathering experience and feedback
Everything pushed to master branch
No relevant changes in the core (planned)
Comes with some helpers
– AsyncExecutor
– Error dialog
32. EventBus 2.1: AsyncExecutor
A thread pool, but with failure handling
RunnableEx interface
– Like Runnable to define code to run async.
– May throw any execption
ThrowableFailureEvent
– Posted when exception occurs
– Throwable object is wrapped inside
– Subclass to customize and filter for type
36. EventBus 2.1: Error Dialog
Operations may fail (networking, etc.)
Some UI response should be shown
– Currently: error dialogs
– Later: Possibly maybe someth. Crouton-ish
Multiple errors: don‟t open multiple times
Goal: Minimize required code
37. How Error Dialogs work
Error handling “attaches” to Activities
Displaying dialogs is triggered by events
ThrowableFailureEvent or subclass
– AsyncExecutor sends those
– Or post those events manually
38. Error Dialogs: Code
// In onCreate in your Activity
ErrorDialogManager.attachTo(this);
// Trigger the dialog
bus.post(new ThrowableFailureEvent(ex));
// Or let AsyncExecutor do it for you…
39. Dialog Configuration
Which texts to display in the dialog?
Simple option: Configure
– Supply default resources for title and text
– Map exception types texts
Flexible option: extend
ErrorDialogFragmentFactory
40. Dialog Configuration: Code
// Initialize in your Application class
ErrorDialogConfig config = new
ErrorDialogConfig(getResources(),
R.string.error_generalTitle,
R.string.error_general);
config.addMapping(UnknownHostException.class,
R.string.error_noInternetConnection);
config.addMapping(IOException.class,
R.string.error_generalServer);
ErrorDialogManager.factory = new
ErrorDialogFragmentFactory.Support(config);
41. Comparison Android
Broadcast
Nice, but somewhat inconvenient
BroadcastReceiver has to be extended
Registration needed for every event type
Extra work to filter for desired event types
(IntentFilter with e.g. ACTION String)
Data is converted into Intent extras
43. Sticky Events
Events can be posted using sticky mode
postSticky(event); // Instead of post(…)
The last sticky event is kept in memory
Registration with getting sticky events
registerSticky(subscriber);
Query for sticky event
getStickyEvent(Class<?> eventType)
Remove sticky event (Class or Object)
removeStickyEvent(Class<?> eventType)
44. Events Class
Event classes are tiny; group them
public class Events {
public static class InitThreadCompleteEvent {
}
public static class LoginCompleteEvent {
}
}
45. EventBusFragment/-Activity
Superclass depends on your setup
Implement in your project
class EventBusFragment extends Fragment {
public void onCreate(…) {
super.onCreate(…);
EventBus.getDefault().register(this);
}
public void onDestroy() {
EventBus.getDefault().unregister(this);
super.onDestroy();
}
46. When to use EventBus
Medium/high distance of components:
“Somewhere” else should happen sth.
Potentially multiple dependencies
Asynchronous logic
When not to use EventBus
– Strictly internal matters:
Use methods and interfaces instead
– Inter-process communication
47. License, Contact
This presentation is licensed under
CreativeCommons ShareAlike/Attribution
http://creativecommons.org/licenses/by-sa/3.0/
Contact greenrobot
– http://greenrobot.de
– http://twitter.com/greenrobot_de
– Google+: http://bit.ly/greenrobotplus