callbacks
Version, currently 0.2.03 versions
- 0.2.0latestFeb 16, 2019
- 0.1.1not indexedMar 25, 2021
- 0.1.0not indexedMar 25, 2021
github.com/vladfaust/callbacks.cr
Expressive callbacks module for Crystal 🚉
Installation
# Add this to your shard.yml
dependencies:
callbacks:
github: vladfaust/callbacks.cr
version: ~> 0.2.0Then run:
shards installshard.yml
- Crystal
0.27.2- License
- MIT
- Author
- Vlad Faust
Dependencies
This version declares no dependencies.
README
Callbacks
An expressive callbacks module for Crystal.
Supporters
Thanks to all my patrons, I can build and support beautiful Open Source Software! 🙏
You can become a patron too in exchange of prioritized support and other perks
About
Callbacks defined with this module are properly inherited and run within a scope of the object itself (i.e. have an access to instance variables etc.).
Installation
Add this to your application's shard.yml:
dependencies:
callbacks:
github: vladfaust/callbacks.cr
version: ~> 0.2.0
This shard follows Semantic Versioning 2.0.0, so see releases and change the version accordingly.
Usage
require "callbacks"
class Foo
include Callbacks
def call
with_callbacks { puts "call" }
end
before do
puts "1"
end
before do
puts "2"
end
after do
puts "3"
end
after do
puts "4"
end
end
Foo.new.call
# 1, 2, call, 3, 4
Objects including Callbacks module can also be inherited preserving all callbacks:
class Bar < Foo
# Childrens before callbacks have higher precedence
before do
puts "5"
end
# Childrens after callbacks executed after parents'
after do
puts "6"
end
end
Bar.new.call
# 5, 1, 2, call, 3, 4, 6
Contributing
- Fork it (https://github.com/vladfaust/callbacks.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- @vladfaust Vlad Faust - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.2.0- Tagged
- Feb 16, 2019
- Commit
48218b1273d6- Crystal
0.27.2- Indexed
- yes
Dependents
Repository
github.com/vladfaust/callbacks.cr
Metadata
- Created
- Aug 16, 2026
- Updated
- Sep 23, 2026
- Synced
- Sep 23, 2026
- Versions
- 3