Skip to content

Commit

Permalink
README additions
Browse files Browse the repository at this point in the history
  • Loading branch information
thisiscetin committed Nov 25, 2024
1 parent da6ea34 commit 9d176db
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ func main() {
Register an event and define your first component.

```go
func main() {
// ... add to main
sirkeji.Subscribe(gStreamer, NewNumberPublisher(gStreamer.Publish))
// ...
}

var Number sirkeji.EventType = "Number"

func init() {
Expand Down Expand Up @@ -116,7 +110,18 @@ func (n NumberPublisher) OnSubscribed() {
func (n NumberPublisher) OnUnsubscribed() {}
```

When you run the application, you will immediately see a partially working software, and an output like below.
Attach your component to the streamer.

```go
func main() {
sirkeji.Subscribe(gStreamer, sirkeji.NewLogger())
sirkeji.Subscribe(gStreamer, NewNumberPublisher(gStreamer.Publish))

sirkeji.WaitForTermination(gStreamer)
}
```

When you run the application, you will **immediately** see working software, a system that can be built brick by brick, and an output like the one below.

```bash
2024/11/26 00:12:38 [logger-1732569158496] subscribed to the streamer
Expand All @@ -127,7 +132,7 @@ When you run the application, you will immediately see a partially working softw
2024/11/26 00:12:42.498675 [number-publisher-1732569158496] *Number*, m: 3 | pl: full
```

Let's create another component which listens for a `Number` event, squares it and emits a `SquaredNumber` event.
Let's create another component that listens for a `Number` event, squares it, and publishes a `SquaredNumber` event.

```go
var SquaredNumber sirkeji.EventType = "SquaredNumber"
Expand Down Expand Up @@ -172,7 +177,7 @@ func (s SquaredNumberPublisher) OnUnsubscribed() {}

```

Don't forget to attach components to the streamer.
Don't forget to attach component to the streamer.

```go
func main() {
Expand All @@ -197,6 +202,8 @@ When you run this code you will see an output like below.
2024/11/26 00:22:54.510833 [squared-number-publisher-1732569771508] *SquaredNumber*, m: 6889 | pl: full
```

*Note: With Sirkeji, you can also subscribe and unsubscribe components dynamically and perform much more complex operations. Please refer to the godoc for details.*

## Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes. Make sure your code is well-tested and aligns with the project's goals.

0 comments on commit 9d176db

Please sign in to comment.