diff --git a/Src/Myc.Core.Lazy.pas b/Src/Myc.Core.Lazy.pas index a04e591..8e0554c 100644 --- a/Src/Myc.Core.Lazy.pas +++ b/Src/Myc.Core.Lazy.pas @@ -62,7 +62,7 @@ type protected function GetValue: T; virtual; abstract; public - constructor Create(const AChanged: TState); + constructor Create(const AChanged: TSignal); destructor Destroy; override; function Pop(out Res: T): Boolean; end; @@ -73,16 +73,7 @@ type protected function GetValue: T; override; public - constructor Create(const AChanged: TState; const AProc: TFunc); - end; - - TMycChainedLazy = class(TMycLazyBase) - private - FValue: TLazy.ILazy; - protected - function GetValue: T; override; - public - constructor Create(const AValue: TLazy.ILazy); + constructor Create(const AChanged: TSignal.ISignal; const AProc: TFunc); end; implementation @@ -159,7 +150,7 @@ end; { TMycLazyBase } -constructor TMycLazyBase.Create(const AChanged: TState); +constructor TMycLazyBase.Create(const AChanged: TSignal); begin inherited Create; FChanged := TFlag.CreateFlag; @@ -189,7 +180,7 @@ end; { TMycFuncLazy } -constructor TMycFuncLazy.Create(const AChanged: TState; const AProc: TFunc); +constructor TMycFuncLazy.Create(const AChanged: TSignal.ISignal; const AProc: TFunc); begin inherited Create(AChanged); FProc := AProc; @@ -201,20 +192,6 @@ begin Result := FProc(); end; -{ TMycChainedLazy } - -constructor TMycChainedLazy.Create(const AValue: TLazy.ILazy); -begin - inherited Create(AValue.Changed); - FValue := AValue; -end; - -function TMycChainedLazy.GetValue: T; -begin - if not FValue.Pop(Result) then - raise Exception.Create('Lazy chain already popped'); -end; - constructor TMycFuncMutable.Create(const AChanged: TSignal; const AProc: TFunc); begin inherited Create(AChanged); diff --git a/Src/Myc.Lazy.pas b/Src/Myc.Lazy.pas index bbe6f1d..c0cfc45 100644 --- a/Src/Myc.Lazy.pas +++ b/Src/Myc.Lazy.pas @@ -73,9 +73,7 @@ type class operator Implicit(const A: ILazy): TLazy; overload; class operator Implicit(const A: TLazy): ILazy; overload; - class function Construct(const Changing: TState; const Proc: TFunc): TLazy; overload; static; - class function Construct(const Value: ILazy): TLazy; overload; static; - + class function Construct(const Changing: TSignal.ISignal; const Proc: TFunc): TLazy; overload; static; class property Null: ILazy read FNull; function Pop(out Res: T): Boolean; inline; @@ -141,7 +139,7 @@ begin FLazy := FNull; end; -class function TLazy.Construct(const Changing: TState; const Proc: TFunc): TLazy; +class function TLazy.Construct(const Changing: TSignal.ISignal; const Proc: TFunc): TLazy; begin Result := TMycFuncLazy.Create(Changing, Proc); end; @@ -151,11 +149,6 @@ begin FNull := TMycNullLazy.Create; end; -class function TLazy.Construct(const Value: ILazy): TLazy; -begin - Result := TMycChainedLazy.Create(Value); -end; - function TLazy.GetChanged: TState; begin Result := FLazy.Changed;