Skip to content

Commit

Permalink
fix: Added code example
Browse files Browse the repository at this point in the history
  • Loading branch information
jlacivita committed Oct 2, 2023
1 parent cb3d6ac commit 2049199
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions requirements/specifications/lifecycle/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ off.
- [4. Core SDK APIs](#4-core-sdk-apis)
- [4.1. LifecycleManagement Interface](#41-lifecyclemanagement-interface)
- [4.2. Ready](#42-ready)
- [4.3. Loading](#43-loading)
- [4.4. Close](#44-close)
- [4.5. Background](#45-background)
- [4.6. Finished](#46-finished)
Expand Down Expand Up @@ -107,7 +106,6 @@ For information on *influencing* state transitions, see [State Transitions](#3-l
| Background ||||| | App has full access to CPU and RAM, but not RCU input focus. |
| Suspended | | | | | | App state is persisted to storage and removed from CPU & RAM. |


### 2.1. Started

This state allows an app to be running, but not in one of the two active
Expand Down Expand Up @@ -609,14 +607,51 @@ The `LifeCycleManagement` interface is implemented by Apps to provide resource m

```typescript
interface LifecycleManagement {
function initialize(): Promise<void>;
function create(params: LaunchParameters): Promise<void>;
function activate(intent: NavigationIntent): Promise<void>;
function deactivate(): Promise<void>;
function suspend(): Promise<void>;
function resume(): Promise<void>;
}
```

Example:

```typescript
import { Lifecycle } from '@firebolt-js/sdk'

class ExampleLifecycleManager implements Lifecycle.LifecycleManagement {
function create(params: LaunchParameters): Promise<void> {
const limitTracking:boolean = params.limitAdTracking
}

function activate(intent: NavigationIntent): Promise<void> {
if (intent.action === "playback") {
console.log("Deep link to playback of " + intent.data.entityId)
}
}

function deactivate(): Promise<void> {
// free up MSE
video.src = ""
video.load()
}

function suspend(): Promise<void> {
// unload all images
document.querySelectorAll("img").forEach((img:HTMLElement) => {
img.parentElement.removeChild(img)
})
}

function resume(): Promise<void> {
// reload images
}
}


```

See the [Firebolt API
Documentation](https://developer.comcast.com/firebolt/core/sdk/latest/api/)
for details around syntax, etc.
Expand Down Expand Up @@ -750,6 +785,8 @@ app to unsuspend.

## 6. Lifecycle Configuration

TODO: do we want these to be per spec, per distributor, or per app?

In order to enable Firebolt Certification of a device's Lifecycle
Management features, the device **MUST** support the following
configuration options, so that the Firebolt Certification Test Suite
Expand Down

0 comments on commit 2049199

Please sign in to comment.