https://github.com/appcypher/observable
https://github.com/appcypher/observable
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/appcypher/observable
- Owner: appcypher
- License: apache-2.0
- Created: 2020-07-21T23:35:50.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-23T13:01:36.000Z (almost 6 years ago)
- Last Synced: 2025-03-05T15:03:24.076Z (over 1 year ago)
- Language: Crystal
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## OBSERVABLE
A simple observable library for personal use really.
### USAGE
- Import into your project
- Add the following in your `shard.yml` file
```yml
dependencies:
agent:
github: appcypher/observable
```
- Import classes into your project
```crystal
require "observable"
class NewsMedia < Observable
getter subscription : Subscription
private def notify()
subscription.notify(self)
end
private def add_subscription(sub : Subscription)
@subscription = subscription
end
def initialize(sub : Subscription)
# ...
add_subscription(sub)
some_source() do |news|
notify()
end
end
# ...
end
class Reader < Observer
def react(obs : Observable)
puts "Wow! That is crazy."
end
end
cnn = NewsMedia.new(Subscription.new)
reader = Reader.new
cnn.subscription.enlist(reader)
```