All Projects → pierrejean-coudert → ReduxDelphi

pierrejean-coudert / ReduxDelphi

Licence: MIT License
ReduxDelphi is a predictable state container for Delphi apps utilizing a unidirectional data flow. Inspired by https://github.com/reactjs/redux .

Programming Languages

pascal
1382 projects

Projects that are alternatives of or similar to ReduxDelphi

pascal-bindings-for-c
How to use libraries created in C with Pascal
Stars: ✭ 24 (-27.27%)
Mutual labels:  object-pascal
xavier
Xavier is a small object-oriented XML library for Lazarus and Delphi
Stars: ✭ 38 (+15.15%)
Mutual labels:  object-pascal
Mastering-FireMonkey-Delphi
✨Embarcadero Delphi - 🔥FireMonkey Sample Applications - Prototypes for inspiration! 🧩
Stars: ✭ 61 (+84.85%)
Mutual labels:  object-pascal
deskew
Deskew is a command line tool for deskewing scanned text documents. It uses Hough transform to detect "text lines" in the image. As an output, you get an image rotated so that the lines are horizontal.
Stars: ✭ 127 (+284.85%)
Mutual labels:  object-pascal
NetCom7
The fastest communications possible. Delphi rulez.
Stars: ✭ 150 (+354.55%)
Mutual labels:  object-pascal
AutoTablesForRADServer
Automate REST API Development With Auto Tables For RAD Server
Stars: ✭ 31 (-6.06%)
Mutual labels:  object-pascal
fano
Pascal web application framework
Stars: ✭ 90 (+172.73%)
Mutual labels:  object-pascal
fano
Pascal web application framework
Stars: ✭ 21 (-36.36%)
Mutual labels:  object-pascal
ofx-reader
💸 💰 OFX (Open Financial Exchange) file formats library
Stars: ✭ 50 (+51.52%)
Mutual labels:  object-pascal
TLightFileStream
Implements a lightweight, high-performance, non-allocating advanced-record-based wrapper around the SysUtils file handling routines as an alternative to Classes.TFileStream.
Stars: ✭ 21 (-36.36%)
Mutual labels:  object-pascal
Photo-Effects
Photo Effects 🧪 Application which is built with Embarcadero Delphi FireMonkey
Stars: ✭ 22 (-33.33%)
Mutual labels:  object-pascal

ReduxDelphi

ReduxDelphi is a predictable state container for Delphi apps utilizing a unidirectional data flow. Inspired by https://github.com/reactjs/redux .

This project is currently developed with Delphi 10.1

The TodoMVC sample is based on immutable data structures (Generic immutable lists).

Counter sample code

Here is a simple example showing the basic usage of Store, Actions, Dispatch,...:

unit DemoCounterForm;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
  Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
  Redux;

type
  TEnumAction= (INIT, INCREMENT, DECREMENT);

  TFormDemoCounter = class(TForm)
    ButtonInc: TButton;
    ButtonDec: TButton;
    LabelCounter: TLabel;

    procedure ButtonIncClick(Sender: TObject);
    procedure ButtonDecClick(Sender: TObject);
    procedure FormShow(Sender: TObject);

  private
    FStore : IStore<Integer, TEnumAction>;
  end;

var
  FormDemoCounter: TFormDemoCounter;

implementation

{$R *.dfm}

procedure TFormDemoCounter.ButtonIncClick(Sender: TObject);
begin
  FStore.dispatch(INCREMENT);
end;

procedure TFormDemoCounter.ButtonDecClick(Sender: TObject);
begin
  FStore.dispatch(DECREMENT);
end;

procedure TFormDemoCounter.FormShow(Sender: TObject);
var
  FReducer : TReducer<Integer,TEnumAction>;
begin
  FReducer :=
    function(State: Integer; Action: TEnumAction): Integer
    begin
      case Action of
        INCREMENT:
          Result := State + 1;
        DECREMENT:
          Result := State - 1;
        else
          Result := State;
      end;
    end;

  FStore := TStore<Integer, TEnumAction>.Create(FReducer, 0);
  FStore.subscribe( procedure (State: Integer)
    begin
      LabelCounter.Caption := IntToStr(State);
    end
  );
  FStore.dispatch(INIT);
end;

end.
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].