Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/startautomating/eventful
Easy Eventful PowerShell
https://github.com/startautomating/eventful
events powershell powershell-module
Last synced: 7 days ago
JSON representation
Easy Eventful PowerShell
- Host: GitHub
- URL: https://github.com/startautomating/eventful
- Owner: StartAutomating
- License: mit
- Created: 2021-11-02T01:55:57.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-13T04:04:57.000Z (over 1 year ago)
- Last Synced: 2024-08-13T07:05:34.348Z (3 months ago)
- Topics: events, powershell, powershell-module
- Language: PowerShell
- Homepage: https://eventful.start-automating.com/
- Size: 264 KB
- Stars: 32
- Watchers: 5
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
Easy Eventful PowerShell
----------------### Getting Started with Eventful
Eventful is a PowerShell module that helps you script asynchronously.
It gives you an easy syntax to describe events handlers in PowerShell, and provides a platform to build custom event sources.
You can watch for events to occur with Watch-Event.
Watch-Event is aliased to "On". For example:~~~PowerShell
# Run in a second
Watch-Event Delay "00:00:01" { "In A Second!" | Out-Host }# Or, using the alias 'On'
on delay "00:05:00" { "Five more minutes!" | Out-Host}
~~~These example use the built-in event source script 'Delay'.
Eventful gives you a way to write scripts that will produce events. These are event sources.
Eventful ships with several event sources. To see what event sources are available to you, run:
~~~PowerShell
Get-EventSource # See event sources
~~~Each event source discovered when Eventful loads creates a smart alias that makes it easier to discover parameters, for example:
~~~PowerShell
# Run in 30 seconds
On@Delay "00:00:30" { "This Message Will Self-Destruct in 30 seconds" | Out-Host }# Run at 5:00 PM
On@Time "5:00 PM" { "End Of Day!" | Out-Host }# Run every 2 minutes
On@Repeat "00:02:00" { "Every other minute" | Out-Host }# Run whenever a file changes within the current directory
On@FileChange { "Files Changed:$($event.SenderEventArgs)" | Out-Host }
~~~Eventful also allows you to handle an arbitrary signal.
In the example below, we set up a handler for "MySignal", and the use the alias send to Send-Event(s).~~~PowerShell
On MySignal {"Fire $($event.MessageData)!" | Out-Host }# Send-Event can accept pipeline input for MessageData, and will not output unless -PassThru is specified.
1..3 | Send MySignal
~~~---
[Understanding Event Sources](Understanding_Event_Sources.md)