Skip to content

Commit

Permalink
feat(progress): finish offCustomGlobalEventByEventName in progress->w…
Browse files Browse the repository at this point in the history
…illUnmount
  • Loading branch information
AmyOrz committed May 19, 2019
1 parent 64f3e73 commit 8a12a22
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/core/atom_component/intInput/IntInput.re
@@ -1,3 +1,4 @@
/* TODO add IntInput_test.re */
type state = {
inputValue: option(string),
isDragStart: bool,
Expand All @@ -9,6 +10,8 @@ type action =
| Blur
| DragDrop;

/* TODO refactor(duplicate) extract from IntInput and FloatInput */

module Method = {
let _change = event => {
let inputVal =
Expand Down
7 changes: 7 additions & 0 deletions src/core/atom_component/progress/Progress.re
Expand Up @@ -76,4 +76,11 @@ let make = (~percent: int, ~completeFunc, _children) => {
|> StateEngineService.setState
|> ignore;
},
willUnmount: _self =>
ManageEventEngineService.offCustomGlobalEventByEventName(
~eventName=ProgressUtils.getProgressCustomGlobalEventName(),
~state=StateEngineService.unsafeGetState(),
)
|> StateEngineService.setState
|> ignore,
};
2 changes: 2 additions & 0 deletions src/service/state/engine/event/ManageEventEngineService.re
Expand Up @@ -10,4 +10,6 @@ let onKeyboardEvent = ManageEventMainService.onKeyboardEvent;

let onCustomGlobalEvent = ManageEventMainService.onCustomGlobalEvent;

let offCustomGlobalEventByEventName = ManageEventMainService.offCustomGlobalEventByEventName;

let unsubscribeDomEventStream = ManageEventMainService.unsubscribeDomEventStream;
3 changes: 2 additions & 1 deletion test/unit/atom_component/progress/Progress_test.re
Expand Up @@ -9,6 +9,7 @@ open Sinon;
let _ =
describe("Progress component", () => {
let sandbox = getSandboxDefaultVal();

let _buildProgressComponent = (percent, completeFunc) =>
ReactTestRenderer.create(<Progress percent completeFunc />);

Expand Down Expand Up @@ -50,7 +51,7 @@ let _ =

completeFunc |> expect |> not_ |> toCalled;
});
test("if percent === 100, execute completeFunc", () => {
test("else if percent === 100, execute completeFunc", () => {
let completeFunc = createEmptyStubWithJsObjSandbox(sandbox);

_buildProgressComponent(80, completeFunc);
Expand Down

0 comments on commit 8a12a22

Please sign in to comment.