All Projects → global-system → DelphiEventBus

global-system / DelphiEventBus

Licence: MIT license
Implementation of event bus pattern for Delphi XE

Programming Languages

pascal
1382 projects
Batchfile
5799 projects

Projects that are alternatives of or similar to DelphiEventBus

LocalTransactionTableTest
利用rabbitmq做消息队列,通过本地消息事务表序列化消息,通过定时轮训保证消息强行落地,最终达到数据最终一致性
Stars: ✭ 19 (-40.62%)
Mutual labels:  eventbus
JPPack
A collection of VCL/LCL components for Delphi/Lazarus - buttons, panels, LinkLabel, ProgressBar, ColorComboBox, ColorListBox, Timer and other
Stars: ✭ 99 (+209.38%)
Mutual labels:  delphi-xe
game-executor
采用Reactor模式,注册readycreate, readyfinish事件到更新服务UpdateService,通过处理后进行模型缓存,然后将消息转化为 dispatchThread消息分配模型需要的create, update, finish的事件进行单线程循环调度 。调度过程使用了系统预置锁模型,来进行多线程唤醒机制,将所有的update循环检测进行多 线程调度,多线程更新服务使用future-listener机制,在完成调度后,根据模型状态,如果模型存活重新将消息转化为update 事件注册到dispatchThread消息分配模型进行循环处理。如果模型死亡将消息转化为readyfinish事件注册到更新服务UpdateServic进行销毁 。这个系统实现了模型自动缓存,多…
Stars: ✭ 28 (-12.5%)
Mutual labels:  eventbus
EventBus
A .NET Core ultra lightweight in-memory event bus implementation.
Stars: ✭ 73 (+128.13%)
Mutual labels:  eventbus
pg-pubsub
Reliable PostgreSQL LISTEN/NOTIFY with inter-process lock support
Stars: ✭ 50 (+56.25%)
Mutual labels:  eventbus
CEventCenter
一个Android事件分发中心库,基于对象池及接口回调实现。实现类似BroadcastReceiver/RxBus/EventBus等的消息事件传递功能,用于在Activity/Fragment/Service之间的消息传递通讯。
Stars: ✭ 116 (+262.5%)
Mutual labels:  eventbus
hub
📨 A fast Message/Event Hub using publish/subscribe pattern with support for topics like* rabbitMQ exchanges for Go applications
Stars: ✭ 125 (+290.63%)
Mutual labels:  eventbus
vxrifa
Utility library for Vert.X that allows using strong-typed interfaces in communication through EventBus
Stars: ✭ 15 (-53.12%)
Mutual labels:  eventbus
dropwizard-guicey-ext
Dropwizard-guicey extensions
Stars: ✭ 11 (-65.62%)
Mutual labels:  eventbus
microservice-architecture-quick-start
Demonstrates how to build a Microservices Architecture using the C # language and the ASP.NET Core environment.
Stars: ✭ 16 (-50%)
Mutual labels:  eventbus
MVPHulk
Android MVP 快速集成方案 (支持AndroidX)
Stars: ✭ 19 (-40.62%)
Mutual labels:  eventbus
StaticBus
🚌 A static bus use in modules.
Stars: ✭ 15 (-53.12%)
Mutual labels:  eventbus
Alpine
Basic event system framework using functional interfaces
Stars: ✭ 79 (+146.88%)
Mutual labels:  eventbus
MVPSamples
🚀(Java 版)快速搭建 MVP + RxJava + Retrofit + EventBus 的框架,方便快速开发新项目、减少开发成本。
Stars: ✭ 113 (+253.13%)
Mutual labels:  eventbus
MASA.Contrib
The purpose of MASA.Contrib is based on MASA.BuildingBlocks to provide open, community driven reusable components for building mesh applications. These components will be used by the MASA Stack and MASA Labs projects.
Stars: ✭ 102 (+218.75%)
Mutual labels:  eventbus
Websockets-Vertx-Flink-Kafka
A simple request response cycle using Websockets, Eclipse Vert-x server, Apache Kafka, Apache Flink.
Stars: ✭ 14 (-56.25%)
Mutual labels:  eventbus
MASA.BuildingBlocks
Building blocks of the MASA Stack, provides a unified interface standard for MASA Contrib's implementation specifications and process connector.
Stars: ✭ 119 (+271.88%)
Mutual labels:  eventbus
mvp4g
A framework to build a gwt application the right way
Stars: ✭ 29 (-9.37%)
Mutual labels:  eventbus
hertzy
Event bus channel
Stars: ✭ 48 (+50%)
Mutual labels:  eventbus
vertx-vue-keycloak
This repo holds the source codes for the Medium Article "Vert.x + VueJS + OAuth2 in 5 steps"
Stars: ✭ 20 (-37.5%)
Mutual labels:  eventbus

DelphiEventBus

Implementation of event bus pattern for Delphi XE

EventBus is designed to provide interaction between different components, without increasing connectivity.

Features

  • Development
    • The type of event is determined by the class.
    • Events are inherited.
    • The base class for any event is TbtkEventObject.
  • Filtering
    • Events can contain filters.
    • Filter values are case sensitive.
    • To declare filters, annotations of event class methods are used.
    • As a filter, functions without parameters are used that should return the filter value as a string.
    • Filters are identified by name.
    • The filter name is specified in the filter annotation.
    • Filter names are not case sensitive.
    • Filters use two modes:
      • Simple mode.
        • The event filter value corresponds to empty and exactly matching handler filter values.
        • This mode is used by default.
      • Hashable mode.
        • The event filter value only matches exactly the same handler filter value.
        • Hashing accelerates the formation of lists of handlers to be called.
    • Filter mode is specified in the filter annotation.
    • The base class contains one hash filter named "Topic"
  • Handlers
    • Adding event handlers is done by registering a listener on the bus.
    • Removal of event handlers is performed by unregistration of the listener in the bus.
    • The filter values of listener event handlers are set after registration.
    • Filter values are bound to the event type, and are equal for different handlers of the same event.
    • To declare handlers, annotations of listener methods are used.
    • Handlers must contain one input parameter with the class type of the event being processed.
    • The type of the handler parameter determines the events that it will process.
    • The handler is invoked for all heirs of the event processed by it.
    • Two types of event handlers are used:
      • Simple handlers.
        • When calling, the filtering conditions are taken into account.
        • The order of the call is not guaranteed.
      • Hooks.
        • Called before calling simple handlers.
        • Ignore filtering conditions.
        • The order of the call corresponds to the reverse order of registration.
    • The type of handler will be determined by annotation.

Example of use

	//event class declaration
	Type
	  TFooEventObject = class(TbtkEventObject)
	  //..........................
	  public
	    const sFooFilterName = 'FooFilter';

	    constructor Create(ATopic: string; AFooFliter: string);

	    [EventFilter(sFooFilterName)] //filter parameter declaration
	    function FooFilter: string;

	  //..........................
	  end;

	//preparation of the listener
	  TFooEventListener = class
	  //..........................
	  public

	    [EventHandler] //handler declaration
	    procedure FooHandler(AFooEvent: TFooEventObject);

	    [EventHook] //hook declaration
	    procedure FooHook(AEventObject: TFooEventObject);

	  //..........................
	  end;

	  EventBus := TbtkEventBus.GetEventBus('FooEventBus');

	  ListenerInfo := EventBus.Register(FooEventListener);

	//setting filter parameters
	  ListenerInfo.HandlerFilters[TFooEventObject][TFooEventObject.sEventFilterTopicName].Value := 'TopicValue';
	  ListenerInfo.HandlerFilters[TFooEventObject][TFooEventObject.sFooFilterName].Value := 'FooFilterValue';

	//creating and sending events
	  EventBus.Send(TFooEventObject.Create('TopicValue', 'FooFilterValue'));

	//listener unregistration
	  EventBus.Unregister(FooListener);

Minimalistic example of use eventhook

	program EventHookExample;

        {$APPTYPE CONSOLE}

        uses
          System.SysUtils,
          btkEventBus;

        type
          TFooEventListener = class
          public
            [EventHook] //hook declaration
            procedure FooHook(EventObject: TbtkEventObject);
          end;

        { TFooEventListener }

        //hook implementation
        procedure TFooEventListener.FooHook(EventObject: TbtkEventObject);
        begin
          Writeln(Format('======'#13#10'Event with topic "%s" sended', [EventObject.Topic]));
        end;

        const
          ebFoo = 'FooEventBus';
        var
          FooEventListener: TFooEventListener;
          FooTopicName: string;
        begin
          //register class for eventbus with name 'FooEventBus'
          RegisterEventBusClass(TbtkEventBus, ebFoo);

          FooEventListener := TFooEventListener.Create;
          try
            //register listener
            EventBus(ebFoo).Register(FooEventListener);

            Write('Write topic: ');
            ReadLn(FooTopicName);

            //create and send event
            EventBus(ebFoo).Send(TbtkEventObject.Create(FooTopicName));
          finally
            FooEventListener.Free;
          end;
          Readln;
        end.

Minimalistic example of use eventhandler

	program EventHookExample;

        {$APPTYPE CONSOLE}

        uses
          System.SysUtils,
          btkEventBus;

        type
          TFooEventListener = class
          public
            [EventHandler] //handler declaration
            procedure FooHandler(EventObject: TbtkEventObject);
          end;

        { TFooEventListener }

        //handler implementation
        procedure TFooEventListener.FooHandler(EventObject: TbtkEventObject);
        begin
          Writeln(Format('Event with topic "%s" sended', [EventObject.Topic]));
        end;

        const
          FooTopicName = 'FooTopic';
        var
          FooEventListener: TFooEventListener;
          FooListenerInfo: TbtkListenerInfo;

        begin
          //register class for eventbus with empty name
          RegisterEventBusClass(TbtkEventBus);

          FooEventListener := TFooEventListener.Create;
          try
            //register listener and get listner info
            FooListenerInfo := EventBus.Register(FooEventListener);

            //set topicfilter for handler
            FooListenerInfo.HandlerFilters.Items[TbtkEventObject].Filters[TbtkEventObject.sEventFilterTopicName].Value := FooTopicName;

            //create and send event
            EventBus.Send(TbtkEventObject.Create(FooTopicName));
          finally
            FooEventListener.Free;
          end;
          Readln;
        end.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].