Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【开源自荐】go-events 是一个 go 实现的事件及事件过滤器库 #33

Open
deatil opened this issue Jul 30, 2024 · 0 comments

Comments

@deatil
Copy link

deatil commented Jul 30, 2024

  • 语言类别:go
  • 项目标题:go-events 事件库
  • 项目描述:go-events 是一个 go 实现的事件及事件过滤器库
package main

import (
    "fmt"
    "github.com/deatil/go-events/events"
)

func main() {
    // use action
    events.AddAction("test1", func() {
        fmt.Println("test1")
    }, events.DefaultSort)
    
    events.DoAction("test1")
    
    // use Filter
    events.AddFilter("test1", func(val string) string {
        return "run test1 => " + val
    }, events.DefaultSort)

    data1 := "init1"
    test := events.ApplyFilters("test1", data1)
    
    fmt.Println(test)
    // output: run test1 => init1 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant