Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/firejox/CrSignals
A signals/slots library in Crystal
https://github.com/firejox/CrSignals
Last synced: about 1 month ago
JSON representation
A signals/slots library in Crystal
- Host: GitHub
- URL: https://github.com/firejox/CrSignals
- Owner: firejox
- License: mit
- Created: 2019-11-29T14:01:54.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-27T14:56:23.000Z (almost 5 years ago)
- Last Synced: 2024-08-01T17:36:03.060Z (4 months ago)
- Language: Crystal
- Homepage:
- Size: 16.6 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-crystal - CrSignals - Signals/slots notification library (Misc)
- awesome-crystal - CrSignals - Signals/slots notification library (Misc)
README
# CrSignals [![Build Status](https://github.com/firejox/CrSignals/workflows/Crystal%20CI/badge.svg?branch=master)](https://github.com/firejox/CrSignals/actions) [![Release](https://img.shields.io/github/v/release/firejox/CrSignals)](https://github.com/firejox/CrSignals/releases)
CrSignals is a signals/slots library. You can define your signal/slot function, wire them and emit data.
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
CrSignals:
github: firejox/CrSignals
```2. Run `shards install`
## Usage
* Here is a basic example of CrSignals library.
```crystal
require "CrSignals"class Foo
include CrSignals::Generator
property x : Int32 = 0cr_signal value_change(Int32)
def set_x(v : Int32)
if @x != v
@x = v
value_change(v)
end
end
enda = Foo.new
b = Foo.newa.connect_value_change(->b.set_x(Int32))
a.set_x(3)
puts b.x # => 3a.disconnect_value_change(->b.set_x(Int32))
a.set_x(4)
puts b.x # => 3
```* If you operate with incorrect type, it will report a compile error.
```crystal
require "CrSignals"class Foo
include CrSignals::Generatorproperty x : Int32 = 0
cr_signal value_change(Int32)
def set_x(v : Float64); end
enda = Foo.new
b = Foo.newa.connect_value_change(->b.set_x(Float64)) # compile error
```## Contributing
1. Fork it ()
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request## Contributors
- [Firejox](https://github.com/firejox) - creator and maintainer