All Projects â†’ SIDOVSKY â†’ DebounceMonitoring

SIDOVSKY / DebounceMonitoring

Licence: MIT license
📑 Add debounce logic for any method in a single line.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to DebounceMonitoring

EBind
🔵 .NET Data Binding we deserve: concise, fast, feature-rich
Stars: ✭ 141 (+220.45%)
Mutual labels:  uwp, wpf, winforms, maui
Microsoft.Toolkit.Win32
This repository contains all controls for WPF and WinForms to simplify and demonstrate usage of UWP controls
Stars: ✭ 345 (+684.09%)
Mutual labels:  uwp, wpf, winforms
Reactiveui
An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms that is inspired by functional reactive programming. ReactiveUI allows you to abstract mutable state away from your user interfaces, express the idea around a feature in one readable place and improve the testability of your application.
Stars: ✭ 6,709 (+15147.73%)
Mutual labels:  uwp, wpf, winforms
Reactivemvvm
Cross-platform ReactiveUI sample app built for a talk at MSK .NET conf.
Stars: ✭ 94 (+113.64%)
Mutual labels:  uwp, wpf, winforms
Csla
A home for your business logic in any .NET application.
Stars: ✭ 865 (+1865.91%)
Mutual labels:  uwp, wpf, winforms
XamlIslands
Repository with several XAML Islands v1 samples (Win32, WPF, and WinForms) to demonstrate how to use it.
Stars: ✭ 47 (+6.82%)
Mutual labels:  uwp, wpf, winforms
dotnet
.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
Stars: ✭ 865 (+1865.91%)
Mutual labels:  uwp, wpf, maui
Windowscommunitytoolkit
The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building UWP and .NET apps for Windows 10. The toolkit is part of the .NET Foundation.
Stars: ✭ 4,654 (+10477.27%)
Mutual labels:  uwp, wpf, winforms
Microsoft.toolkit.win32
This repository contains all controls for WPF and WinForms to simplify and demonstrate usage of UWP controls
Stars: ✭ 257 (+484.09%)
Mutual labels:  uwp, wpf, winforms
SciColorMaps
Custom .NET color maps (user-defined or imported from matplotlib) for scientific visualization
Stars: ✭ 26 (-40.91%)
Mutual labels:  uwp, wpf, winforms
WindowsCommunityToolkit
The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building UWP and .NET apps for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
Stars: ✭ 4,934 (+11113.64%)
Mutual labels:  uwp, wpf, winforms
AsteroidsWasm
Collection of applications based on a single C# .NET Standard project running in: Blazor Client (WebAssembly), Blazor Server, Electron, WPF, WinForms, Xamarin
Stars: ✭ 136 (+209.09%)
Mutual labels:  uwp, wpf, winforms
Live Charts
Simple, flexible, interactive & powerful charts, maps and gauges for .Net
Stars: ✭ 5,045 (+11365.91%)
Mutual labels:  uwp, wpf, winforms
Reactiveproperty
ReactiveProperty provides MVVM and asynchronous support features under Reactive Extensions. Target framework is .NET Standard 2.0.
Stars: ✭ 603 (+1270.45%)
Mutual labels:  uwp, wpf, rx
Adaptivecards
A new way for developers to exchange card content in a common and consistent way.
Stars: ✭ 950 (+2059.09%)
Mutual labels:  uwp, wpf
Mvvmlight
The main purpose of the toolkit is to accelerate the creation and development of MVVM applications in Xamarin.Android, Xamarin.iOS, Xamarin.Forms, Windows 10 UWP, Windows Presentation Foundation (WPF), Silverlight, Windows Phone.
Stars: ✭ 973 (+2111.36%)
Mutual labels:  uwp, wpf
Mahapps.metro.iconpacks
Awesome icon packs for WPF and UWP in one library
Stars: ✭ 1,157 (+2529.55%)
Mutual labels:  uwp, wpf
Helix Toolkit
Helix Toolkit is a collection of 3D components for .NET.
Stars: ✭ 1,050 (+2286.36%)
Mutual labels:  uwp, wpf
Xamarin Forms Gtk Movies Sample
The Movie DB Xamarin.Forms Sample
Stars: ✭ 83 (+88.64%)
Mutual labels:  uwp, wpf
Catel
An application development platform
Stars: ✭ 616 (+1300%)
Mutual labels:  uwp, wpf

LOGO

DebounceMonitoring

CI PLATFORM NuGet

Extensions to filter out repeated function calls caused by false or accidental clicks or touches.

  • One-line integration
  • Inlined, no method wrapping
  • Shareable between multiple platforms
  • Automated testing friendly

Installing

Add NuGet package to your .NET Standard 2.0 - compatible project

PM> Install-Package DebounceMonitoring

Usage

using DebounceMonitoring;

Debounce instance methods:

internal class ViewModel
{
    public void OnButtonClick()
    {
        if (this.DebounceHere()) return;

        // Handle the click
    }
}

snippet source

Debounce lambdas and local functions:

public Command ClickCommand { get; }

public ViewModel()
{
    ClickCommand = new Command(() =>
    {
        if (this.DebounceHere()) return;

        // Handle the click
    });
}

snippet source

Debounce static methods:

internal class Analytics
{
    public static void TrackEvent()
    {
        if (DebounceMonitor.DebounceHereStatic<Analytics>()) return;

        // Send the event
    }
}

snippet source

Rx Operator

This library also provides the simplest implementation of the debounce operator for Rx.NET (throttle in RxJs).

Example:

button.ClickAsObservable()
    .Debounce()
    .Subscribe(_ => OnButtonClick());

snippet source

Interval

The default debounce interval is 500 ms.
It can be specified as an argument:

this.DebounceHere(intervalMs: 1_000)

IObservable<T>.Debounce(intervalMs: 1_000)

or set globally:

DebounceMonitor.DefaultInterval = TimeSpan.FromSeconds(5);

Disable (for automated testing)

The DebounceMonitor can be disabled in your base TestFixture.Setup or globally in ModuleInitializer with ModuleInitializerAttribute or Fody.ModuleInit.

internal static class UnitTestGlobalSetup
{
    [System.Runtime.CompilerServices.ModuleInitializer]
    internal static void SetupDebounceMonitor() => DebounceMonitor.Disabled = true;
}

snippet source

How does it work?

When this.DebounceHere is called, the call time is mapped to its location (method name + line number) and target (this in this case).

On the next call, the time is compared to the stored one. If the interval has not yet passed, then the call is meant to be debounced.

The debounce target (reference) is held weakly, so no memory leaks are caused.

License

This project is licensed under the MIT license - see the LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].