Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f7aa3e1

Browse files
committed
BiFunctor
1 parent 1620f18 commit f7aa3e1

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

‎src/fantasy.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { HKTS, HKT, streamOps } from './xs'
2-
import { Plan, Xcomponent, XcomponentClass, Engine, Update, XProps, ContextEngine, XREACT_ENGINE } from './interfaces'
2+
import { Plan, Actions,Xcomponent, XcomponentClass, Engine, Update, XProps, ContextEngine, XREACT_ENGINE } from './interfaces'
33
import { XOrReactComponent, x } from './x'
44
import { extendXComponentClass, genXComponentClass } from './xclass'
55

@@ -50,6 +50,20 @@ export class PlanX<E extends HKTS, I, A> {
5050
return { update$, actions: machine.actions }
5151
})
5252
}
53+
54+
bimap<B>(
55+
fu: (a: Update<A>) => Update<B>,
56+
fa: (a: Actions<I>) => Actions<I>
57+
): PlanX<E, I, B> {
58+
return new PlanX<E, I, B>(intent$ => {
59+
let machine = this.apply(intent$)
60+
let update$ = streamOps.map<Update<A>, Update<B>>(
61+
update => fu(update),
62+
machine.update$
63+
)
64+
return { update$, actions: fa(machine.actions) }
65+
})
66+
}
5367
}
5468

5569
export class FantasyX<E extends HKTS, I, S> {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /