Два варианта решения, кому-то обязательно пригодится.
Вариант 1import * as ts from 'typescript';
import {of} from 'rxjs/observable/of';
import {concat} from 'rxjs/observable/concat';
private createTranslateChangedEpic() {
const g = Groups.getSelectedGroupForSelectedPerspective(storeState);
const reportId1 = storeState.groups[0].id;
const reportId2 = storeState.groups[1].id;
const code = `({
Run: (concat: <T>, of: <T>, actions: SummaryActivitySitesActions, reportId1, reportId2) => {
console.log('run');
return concat(
of(actions.setPage(reportId1, {page: 1})).delay(100),
of(actions.setPage(reportId2, {page: 1})).delay(100)
);
}
})`;
const result = ts.transpile(code);
const runnalbe = eval(result);
return runnalbe.Run(concat, of, this.actions, reportId1, reportId2);
}
Вариант 2private createTranslateChangedEpic() {
const g = Groups.getSelectedGroupForSelectedPerspective(storeState);
const reportId1 = storeState.groups[0].id;
const reportId2 = storeState.groups[1].id;
const f = new Function(
'concat',
'of',
'actions',
'reportId1',
'reportId2',
`return function (concat, of, actions, reportId1, reportId2) {
console.log('run');
return concat(
of(actions.setPage(reportId1, {page: 1})).delay(100),
of(actions.setPage(reportId2, {page: 1})).delay(100)
);
}`
)(concat, of, this.actions, reportId1, reportId2);
return f(concat, of, this.actions, reportId1, reportId2);
}