mathieuprog / tz

Time zone support for Elixir
Apache License 2.0
147 stars 11 forks source link

Allow Tz.WatchPeriodically to accept and call a function when triggered. #10

Closed OldhamMade closed 2 years ago

OldhamMade commented 2 years ago

Since using Tz.UpdatePeriodically on memory-restricted platforms may not be possible, it would be useful if Tz.WatchPeriodically could call a function whenever it logs that there is an update. This would allow users of the library to do something proactive, like trigger an email or SMS.

mathieuprog commented 2 years ago

I added the following options to Tz.WatchPeriodically (not yet published)

{
  Tz.WatchPeriodically, 
    interval_in_days: 5,
    on_update: fn version ->
      IO.inspect "New update available #{version}!"
    end
}

Is the naming on_update okay?

mathieuprog commented 2 years ago

Released in v0.21. Let me know if you have any feedback.