GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — opencode-mobile/shared/observability/lifecycle.ts at main · drpr/opencode-mobile

Expand file tree

/

lifecycle.ts

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
25 lines (22 loc) · 1007 Bytes
/

lifecycle.ts

Copy path

File metadata and controls

25 lines (22 loc) · 1007 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { AppState } from 'react-native';
import type { Observability } from '@/shared/observability/types';
let installed = false;
// Lifecycle instrumentation is intentionally tiny: one AppState listener, no
// timers while backgrounded, and a best-effort flush on the way out.
export function installObservabilityLifecycle(target: Observability) {
if (installed) return;
installed = true;
let backgroundedAt = AppState.currentState === 'active' ? 0 : Date.now();
target.markStartup('lifecycle');
AppState.addEventListener('change', (state) => {
if (state === 'active') {
const backgroundedFor = backgroundedAt ? Math.max(0, Date.now() - backgroundedAt) : 0;
backgroundedAt = 0;
target.info('app.lifecycle', { phase: 'foreground', foreground: true, durationMs: backgroundedFor });
} else {
if (!backgroundedAt) backgroundedAt = Date.now();
target.info('app.lifecycle', { phase: 'background', foreground: false });
void target.flush();
}
});
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.