|
1 | 1 | 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' |
3 | 3 | import { XOrReactComponent, x } from './x'
|
4 | 4 | import { extendXComponentClass, genXComponentClass } from './xclass'
|
5 | 5 |
|
@@ -50,6 +50,20 @@ export class PlanX<E extends HKTS, I, A> {
|
50 | 50 | return { update$, actions: machine.actions }
|
51 | 51 | })
|
52 | 52 | }
|
| 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 | + } |
53 | 67 | }
|
54 | 68 |
|
55 | 69 | export class FantasyX<E extends HKTS, I, S> {
|
|
0 commit comments