observable alternatives and similar shards
Based on the "Misc" category.
Alternatively, view observable alternatives based on common mentions on social networks and blogs.
-
sentry
Build/Runs your crystal application, watches files, and rebuilds/restarts app on file changes -
immutable
Thread-safe, persistent, immutable collections for the Crystal language -
crystagiri
An Html parser library for Crystal (like Nokogiri for Ruby) -
crz
Functional programming library for https://github.com/crystal-lang/crystal -
crystal-web-framework-stars
⭐️ Web frameworks for Crystal, most starred on Github -
cron_scheduler
Simple job scheduler with crontab patterns for Crystal Language. -
crystal-futures
Future type implementation for Crystal language -
inflector.cr
Inflector shard for Crystal. A port of ActiveSupport::Inflector -
aasm.cr
:arrows_clockwise: Easy to use finite state machine for Crystal classes -
kreal
Kreal is a model sharing & RPC library built on and works with Kemal seamlessly. -
retriable.cr
Retriable.cr is a simple DSL to retry failed code blocks -
ulid
Universally Unique Lexicographically Sortable Identifier (ULID) in Crystal -
CrSerializer
Extensible annotation based serialization/deserialization library -
circuit_breaker
Implementation of the circuit breaker pattern in crystal -
burocracia.cr
No dependency Crystal shard to validate, generate and format Brazilian burocracias such as CPF, CNPJ and CEP -
wikicr
Wiki in crystal, using Markdown and Git, inspired by dokuwiki. Last features to build are pretty hard, if you have some time to help... :) -
m3u8
Generate and parse m3u8 playlists for HTTP Live Streaming (HLS) in Crystal. -
message_verifier.cr
Rails compatible MessageVerifier for Crystal-lang apps
Static code analysis for 29 languages.
Do you think we are missing an alternative of observable or a related project?
README
observable 
Simple implementation of the Observer pattern in Crystal. It is loosely based on the Observable module from Ruby :)
The observer pattern is used to avoid tightly coupling objects that stand in a one-to-many relationship. It allows you to notify dependents about changes that happened to your object, without having hard-coded dependencies :)
Installation
Add to your shard.yml
dependencies:
observable:
github: tpei/observable
branch: master
and then install the library into your project with
$ crystal deps
Usage
Include observable in the class you want to observe:
require "observable/observable"
class ToObserve
include Observable
end
This provides you with the following methods:
add_observer(observer : Observer)
changed(state=true)
changed?
count_observers
delete_observer(observer : Observer)
delete_observers
notify_observers
and as an added bonus, because I dislike the forced changed
call precondition:
notify_observers!
, which notifies no matter if changed or not
Then you can include observer in the class you want observing:
require "observable/observer"
class Observing
include Observer
def update(observable : Observable)
# do whatever you want to do if your observable changes
end
end
This only gives you an update(observable : Observable)
method you should override, because it willl raise an error otherwise.
Unfortunately we don't have ruby's verbosity and dynamism here so it's all a little more static. Especially the update
method can really only pass on the observable
object.