Skip to content

Commit 44e2fa9

Browse files
committed
feat(ikari): remove unnecessary setup
1 parent 27d4d36 commit 44e2fa9

File tree

2 files changed

+1
-36
lines changed

2 files changed

+1
-36
lines changed

src/core/ikari.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ export class Ikari<State> {
7777
return createdIkari
7878
} else {
7979
const ikari = new Ikari(config)
80-
ikari.setup()
8180
Reflect.defineMetadata(ikariSymbol, ikari, target)
8281
return ikari
8382
}
@@ -95,17 +94,9 @@ export class Ikari<State> {
9594

9695
subscription = new Subscription()
9796

98-
private isSetup: boolean = false
99-
10097
constructor(private readonly config: Readonly<Config<State>>) {
10198
this.effectActionFactories = config.effectActionFactories
10299
this.state = new BasicState<State>(config.defaultState)
103-
}
104-
105-
setup() {
106-
if (this.isSetup) {
107-
return
108-
}
109100

110101
const [effectActions$, effectActions] = setupEffectActions(
111102
this.config.effects,
@@ -136,8 +127,6 @@ export class Ikari<State> {
136127
this.handleAction(action)
137128
}),
138129
)
139-
140-
this.isSetup = true
141130
}
142131

143132
destroy() {

test/specs/ikari.spec.ts

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,9 @@ describe('Ikari spec:', () => {
4141
})
4242
})
4343

44-
describe('setup', () => {
44+
describe('instance', () => {
4545
const ikari = createIkari()
4646

47-
it('`setup` actually run once', () => {
48-
ikari.setup()
49-
const firstTriggerActions = ikari.triggerActions
50-
51-
ikari.setup()
52-
const secondTriggerActions = ikari.triggerActions
53-
54-
expect(firstTriggerActions).toBe(secondTriggerActions)
55-
})
56-
})
57-
58-
describe('after setup', () => {
59-
const ikari = createIkari()
60-
61-
ikari.setup()
62-
6347
it('state is setup properly', () => {
6448
expect(ikari.state).toBeInstanceOf(BasicState)
6549
expect(ikari.state.getState()).toEqual({ count: 0 })
@@ -81,8 +65,6 @@ describe('Ikari spec:', () => {
8165
describe('after destroy', () => {
8266
const ikari = createIkari()
8367

84-
ikari.setup()
85-
8668
expect(ikari.subscription.closed).toBe(false)
8769

8870
beforeEach(() => {
@@ -96,11 +78,5 @@ describe('Ikari spec:', () => {
9678
it('should remove all triggerActions', () => {
9779
expect(ikari.triggerActions).toEqual({})
9880
})
99-
100-
it('should not able to reactive', () => {
101-
ikari.setup()
102-
expect(ikari.subscription.closed).toBe(true)
103-
expect(ikari.triggerActions).toEqual({})
104-
})
10581
})
10682
})

0 commit comments

Comments
 (0)