Skip to content

Commit 6e4841b

Browse files
author
DM
committed
docs
1 parent 43d3322 commit 6e4841b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

examples/eval-box.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
import { filter, map, Subject } from 'rxjs';
1+
import { Subject, filter, map } from 'rxjs';
22
import { rml, inputPipe, Value } from 'rimmel';
33

44
export const EvalBox = (data: ICollection<ItemType, string>) => {
55
const FromInputBox = inputPipe(map((e: Event) => (<HTMLElement>e.target)!.parentElement!.querySelector('input')!.value));
66
const OnEnter = inputPipe(filter((e: KeyboardEvent) => e.key == 'Enter'));
77

88
const stream = new Subject<string>().pipe(
9-
map((x) => eval(`${x}`)),
9+
map((x) => {
10+
try {
11+
return eval(`${x}`);
12+
} catch(e) {
13+
return `Error: ${e.message}`;
14+
}
15+
}),
1016
map((x) => `<pre class="eval-result">${JSON.stringify(x, null, 2)}</pre>`),
1117
);
1218

@@ -23,4 +29,3 @@ export const EvalBox = (data: ICollection<ItemType, string>) => {
2329
`;
2430
}
2531

26-

examples/kitchen-sink.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface ItemType {
1818
const App = () => {
1919
const Item = (title: string): ItemType => ({
2020
title,
21-
rnd: Math.round(Math.random() *1000),
21+
rnd: Math.round(Math.random() *899 +100),
2222
get [Symbol.toStringTag]() { return `"${this.title}"` },
2323
});
2424
const initialValues = [...Array(10)].map((x, i)=>`Item ${i}`);

0 commit comments

Comments
 (0)