All Projects → agoalofalife → event

agoalofalife / event

Licence: MIT License
The implementation of the pattern observer

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to event

Opendataday
Open Data Day website
Stars: ✭ 70 (+55.56%)
Mutual labels:  events, event
Noel
A universal, human-centric, replayable javascript event emitter.
Stars: ✭ 158 (+251.11%)
Mutual labels:  events, event
spa-bus
🔥Tools for multilevel components to pass values in any SPA
Stars: ✭ 15 (-66.67%)
Mutual labels:  events, event
React Native Add Calendar Event
Create, view or edit events in react native using the standard iOS / Android dialogs
Stars: ✭ 225 (+400%)
Mutual labels:  events, event
EventEmitter
Simple EventEmitter with multiple listeners
Stars: ✭ 19 (-57.78%)
Mutual labels:  events, event
dead-simple
💀💡 Dead simple PubSub and EventEmitter in JavaScript
Stars: ✭ 21 (-53.33%)
Mutual labels:  events, event
Ease
It's magic.
Stars: ✭ 1,213 (+2595.56%)
Mutual labels:  events, event
tiny-typed-emitter
Fully type-checked NodeJS EventEmitter
Stars: ✭ 96 (+113.33%)
Mutual labels:  events, event
evon
Fast and versatile event dispatcher code generator for Golang
Stars: ✭ 15 (-66.67%)
Mutual labels:  events, event
Chordly
Chordly is a javascript library that may be used to detect and act upon key sequences entered by a user.
Stars: ✭ 14 (-68.89%)
Mutual labels:  events, event
PoShLog
🔩 PoShLog is PowerShell cross-platform logging module. It allows you to log structured event data into console, file and much more places easily. It's built upon great C# logging library Serilog - https://serilog.net/
Stars: ✭ 108 (+140%)
Mutual labels:  events, event
Klendario
A Swift wrapper over the EventKit framework
Stars: ✭ 44 (-2.22%)
Mutual labels:  events
skywalking-kubernetes-event-exporter
Export Kubernetes events to Apache SkyWalking OAP.
Stars: ✭ 25 (-44.44%)
Mutual labels:  event
2019.djangocon.us
⛵ The DjangoCon US 2019 conference website
Stars: ✭ 18 (-60%)
Mutual labels:  events
burns
Manage your application's events without writing spaghetti code
Stars: ✭ 86 (+91.11%)
Mutual labels:  events
cute
An event-centric publisher/subscribe model for objects inspired by the Qt framework
Stars: ✭ 37 (-17.78%)
Mutual labels:  events
observable ish
Observable state and events for browser and Flutter.
Stars: ✭ 26 (-42.22%)
Mutual labels:  events
moodle-tool trigger
Like IFTTT for Moodle: events to trigger external services. https://moodle.org/plugins/tool_trigger
Stars: ✭ 32 (-28.89%)
Mutual labels:  event
THREE.Interactive
Fast and simple interaction manager for three.js for enabling mouse and touch events on 3D objects
Stars: ✭ 49 (+8.89%)
Mutual labels:  events
networkdays
Networkdays functions ... including `networkdays` excel like function with no dependencies (no NumPy)
Stars: ✭ 22 (-51.11%)
Mutual labels:  events

Event

Build Status codecov Go Report Card GoDoc

This is package implements pattern-observer

Fast example

import (
	"github.com/agoalofalife/event"
)

func main() {
	// create struct
	e := event.New()

	// subscriber 
	e.Add("push.email", func(text string){
    	// some logic 
    }, "text")
    
    // init event
    e.Fire("push.email") // or e.Go("push.email")
}

let us consider an example:

  • You must first create the structure
  • Next, the first argument declares the name of the event (string type), second argument executes when the event occurs, the third argument is passed a list of arguments, which are substituted in the parameters of the second argument.
  • In the end you need to run the event. There are two methods available "Go" and his alias "Fire"

The subscriber function method

type Email struct {
	count int
}
func (e *Email) Push() {
	e.count += 1
	fmt.Printf("Push email again, count %d \n", e.count)
}
func main() {
	e := event.New()
	
	email := new(Email)
	
	e.Add(email, email.Push)
	e.Fire(email)
	e.Fire(email)
}
// output 
// Push email again, count 1 
// Push email again, count 2 

Bench

// create struct and add new event handler
BenchmarkAdd-8           1000000              1482 ns/op

// create struct and add new event handler and N run this handler
BenchmarkGo-8            5000000               339 ns/op

  • In this example we sign the event method structure

Read more information in examples 👍

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].