1 | export const frameStack = [];
|
2 | export function topmost() {
|
3 | if (frameStack.length > 0) {
|
4 | return frameStack[frameStack.length - 1];
|
5 | }
|
6 | return undefined;
|
7 | }
|
8 | export function _pushInFrameStack(frame) {
|
9 | if (frame._isInFrameStack && frameStack[frameStack.length - 1] === frame) {
|
10 | return;
|
11 | }
|
12 | if (frame._isInFrameStack) {
|
13 | const indexOfFrame = frameStack.indexOf(frame);
|
14 | frameStack.splice(indexOfFrame, 1);
|
15 | }
|
16 | frameStack.push(frame);
|
17 | frame._isInFrameStack = true;
|
18 | }
|
19 | export function _popFromFrameStack(frame) {
|
20 | if (!frame._isInFrameStack) {
|
21 | return;
|
22 | }
|
23 | const top = topmost();
|
24 | if (top !== frame) {
|
25 | throw new Error('Cannot pop a Frame which is not at the top of the navigation stack.');
|
26 | }
|
27 | frameStack.pop();
|
28 | frame._isInFrameStack = false;
|
29 | }
|
30 | export function _removeFromFrameStack(frame) {
|
31 | if (!frame._isInFrameStack) {
|
32 | return;
|
33 | }
|
34 | const index = frameStack.indexOf(frame);
|
35 | frameStack.splice(index, 1);
|
36 | frame._isInFrameStack = false;
|
37 | }
|
38 |
|
\ | No newline at end of file |