Skip to content

Commit

Permalink
Added THorse.AddCallbacks([])
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciussanchez committed Feb 16, 2022
1 parent 8f46ee3 commit 0861472
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Horse.Core.pas
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ THorseCore = class
constructor Create; virtual;
class function ToModule: THorseModule;
class destructor UnInitialize; {$IFNDEF FPC}virtual; {$ENDIF}

class function AddCallback(ACallback: THorseCallback): THorseCore;
class function AddCallbacks(ACallbacks: TArray<THorseCallback>): THorseCore;

class function Group(): IHorseCoreGroup<THorseCore>;
class function Route(APath: string): IHorseCoreRoute<THorseCore>;
class function Use(APath: string; ACallback: THorseCallback): THorseCore; overload;
Expand Down Expand Up @@ -128,12 +131,21 @@ implementation

class function THorseCore.AddCallback(ACallback: THorseCallback): THorseCore;
begin
result := GetDefaultHorse;
Result := GetDefaultHorse;
if FCallbacks = nil then
FCallbacks := TList<THorseCallback>.create;
FCallbacks := TList<THorseCallback>.Create;
FCallbacks.Add(ACallback);
end;

class function THorseCore.AddCallbacks(ACallbacks: TArray<THorseCallback>): THorseCore;
var
LCallback: THorseCallback;
begin
for LCallback in ACallbacks do
AddCallback(LCallback);
Result := GetDefaultHorse;
end;

constructor THorseCore.Create;
begin
if FDefaultHorse <> nil then
Expand Down

0 comments on commit 0861472

Please sign in to comment.