loqmanali / once

Want to run a piece of code once (Only - Week - Month - Year - Any duration)? We got you.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

once

Want to run a piece of code once (Once - Hourly - Daily - Weekly - Monthly - Every new vetsion - Any Custom duration)? We got your back.


Some things should happen once.

  • Users should only get the guided tour once.
  • Release notes should only pop up once every mew app version come.
  • Your app should only phone home to update content once every hour.
  • Etc.. once every (What ever you want).

Once supports runOnce, runOnEveryNewVersion, runEvery12Hours, runHourly, runDaily, runWeekly, runMonthly, runOnNewMonth, runYearly and Custom (Duration).

Usage

Done on the time that you want the thing to be done

Now you're ready to go. Say you wanted to show the new features dialog when the app is updated:

Once.runOnEveryNewVersion(() {
    /* What's new in 2.3.2 version? dialog */
});

Or maybe you want to show the rate this app dialog every week for the user:

if (!rated){
  Once.runWeekly("ratingDialog",() { 
    /* Like our app, Please rate us. dialog */ 
  });
}

Contributors

inspired by the java library Once made by Jon Finerty

About

Want to run a piece of code once (Only - Week - Month - Year - Any duration)? We got you.

License:MIT License


Languages

Language:Dart 84.1%Language:Ruby 11.2%Language:Swift 3.3%Language:Kotlin 1.1%Language:Objective-C 0.3%