back

by stevekrouse·3y ago·view on hn ↗
Great questions! The short answer is yes: the val namespace can act as a persistent key/value store. Type write `@me.citationCount = 7` anywhere in your code, and that will work. The downside is that this is a global store of state, so it's harder to build composable functions that have persistent state. We're working on designs for this!

You are totally right about the fire season script getting annoying. We should probably also have some mutable state there so that it only notifies you once when it goes above the threshold and then once when it's back safe again.

1 comments
> Type write `@me.citationCount = 7` anywhere in your code, and that will work.

That is elegant. I like it.

> only notifies you once when it goes above the threshold and then once when it's back safe again.

It might also be a good idea to add an argument to the email function to tell it not send an identical email to the previous email sent within a window (or ever). So just fire off your citation count email, knowing that you will only actually be send an email when count changes.

This simplifies the scripts, while offloading a bit more work and persistance to the API.