Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pbojinov/first-time
For all those times you want some code to only run once...
https://github.com/pbojinov/first-time
Last synced: 5 days ago
JSON representation
For all those times you want some code to only run once...
- Host: GitHub
- URL: https://github.com/pbojinov/first-time
- Owner: pbojinov
- License: mit
- Created: 2015-07-02T10:20:09.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-16T07:26:06.000Z (almost 9 years ago)
- Last Synced: 2024-10-12T03:09:04.964Z (about 1 month ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# First Time
> For all those times you want some code to only run once...
![Build Status](https://api.travis-ci.org/pbojinov/first-time.svg?branch=master)
## Install
```bsh
bower install first-time --save
```Then add it to your app:
```html
```
## API
``` javascript
// Ask if this event has already happened
FirstTime.hasItHappened('a_revolution') // => false
`````` javascript
// Tell `FirstTime` that the event has already happened
FirstTime.itHappened('a_revolution') // => undefined
```## Examples
``` javascript
if (!FirstTime.hasItHappened('a_revolution')) {
// bear arms, then...
FirstTime.itHappened('a_revolution');
console.log('bear arms');
} else {
// go home
console.log('go home, no revolution yet');
}
```## Coming Soon
A promised based approach
``` javascript
FirstTime.makeItHappen('a_revolution').then(function() {
// run some code only the first time
// it will automatically handle calling `itHappened` for you
});
```## License
The MIT License (MIT)