Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/galadril/Xam.Plugin.Once
A simple Xamarin Forms library to manage one-off operations.
https://github.com/galadril/Xam.Plugin.Once
forms library once plugin preferences xamarin xamarin-library
Last synced: 3 months ago
JSON representation
A simple Xamarin Forms library to manage one-off operations.
- Host: GitHub
- URL: https://github.com/galadril/Xam.Plugin.Once
- Owner: galadril
- License: mit
- Created: 2020-03-20T09:52:20.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-08-13T12:50:19.000Z (about 1 year ago)
- Last Synced: 2024-06-30T04:54:54.980Z (4 months ago)
- Topics: forms, library, once, plugin, preferences, xamarin, xamarin-library
- Language: C#
- Homepage: https://www.nuget.org/packages/Xam.Plugin.Once
- Size: 576 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-xamarin-forms - Xam.Plugin.Once ★7 - off operations. (Plugins)
README
[![Nuget](https://img.shields.io/nuget/v/Xam.Plugin.Once)](https://www.nuget.org/packages/Xam.Plugin.Once) ![Nuget](https://img.shields.io/nuget/dt/Xam.Plugin.Once)
![Icon](https://raw.githubusercontent.com/galadril/Xam.Plugin.Once/master/Samples/Xam.Plugin.Once.Samples/Xam.Plugin.Once.Samples.Android/Resources/mipmap-xxhdpi/ic_launcher.png)
# Xam.Plugin.Once
Just a nice and library that allows you to do something once for your Xamarin Forms project.!!This was inspired by the Once library for Android made by jonfinerty!!
https://github.com/jonfinerty/Once----
Some things should happen **once**.
* Users should only get the guided tour _once_.
* Release notes should only pop up _once every app upgrade_.
* Your app should only phone home to update content _once every hour_.`Once` provides a simple API to track whether or not your app has already performed an action within a given scope.
# Setup
* Available on Nuget:
https://www.nuget.org/packages/Xam.Plugin.Once!!Install into your .net standard Forms project. !!
# Usage
Here are some examples on how to use Once for Xamarin Forms:- Only run the app intro once
```
Once.Instance.RunWhen(SHOW_APP_INTRO, new Command(() => UserDialogs.Instance.Toast("Show app intro")));
```- Only show a survey every 30 days for the first time, then after 90 days
```
if(Once.Instance.LastRunAt(SHOW_SURVEY) == null)
Once.Instance.RunWhen(SHOW_SURVEY, new Command(() => UserDialogs.Instance.Toast("Show app survey")), false, new After() {RunAfter = 30, Type = After.AfterType.Days });
else
Once.Instance.RunWhen(SHOW_SURVEY, new Command(() => UserDialogs.Instance.Toast("Show app survey")), false, new After() {RunAfter = 90, Type = After.AfterType.Days });
```- Just to check if we need to show the app intro
```
_ = Once.Instance.NeedsToRun(SHOW_APP_INTRO);
```- Mark a task to done
```
Once.Instance.MarkRunAsDone(SHOW_APP_CHANGELOG);
```(see sample project for more info)
# Donation
If you like to say thanks, you could always buy me a cup of coffee (/beer)!
(Thanks!)
[![PayPal donate button](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.me/markheinis)