|
| 1 | +--- |
| 2 | +id: interfaces |
| 3 | +title: Interfaces |
| 4 | +sidebar_label: Interfaces |
| 5 | +slug: /interfaces |
| 6 | +--- |
| 7 | + |
| 8 | +:::info |
| 9 | + |
| 10 | +Here are all documented Interfaces of AgileTs listed! |
| 11 | + |
| 12 | +::: |
| 13 | + |
| 14 | + |
| 15 | +### `CreateLoggerConfig` |
| 16 | + |
| 17 | +```ts |
| 18 | +export interface CreateLoggerConfigInterface { |
| 19 | + prefix?: string; |
| 20 | + allowedTags?: string[]; |
| 21 | + canUseCustomStyles?: boolean; |
| 22 | + active?: boolean; |
| 23 | + level?: number; |
| 24 | + timestamp?: boolean; |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +| Prop | Type | Default | Description | Required | |
| 29 | +|----------------------|----------|--------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|----------| |
| 30 | +| `level` | number | 20 (Logger.level.WARN) | On which 'level' the logger should log. For instance if it only should log Errors. | No | |
| 31 | +| `active` | boolean | true | If the Logger is active. | No | |
| 32 | +| `timestamp` | boolean | false | If a Timestamp gets applied for each Log Message. | No | |
| 33 | +| `allowedTags` | string[] | ['runtime', 'storage', 'subscription', 'multieditor'] | Sometimes logs are marked with Tags. If this is the case, the log gets only logged if the Tag is included. | No | |
| 34 | +| `canUseCustomStyles` | boolean | true | If the Logger is allowed to apply css styles to the Logs. For instance Agile Logs are by default purple. | No | |
| 35 | + |
| 36 | + |
| 37 | +<br/> |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +<br/> |
| 42 | + |
| 43 | + |
| 44 | +### `StorageMethods` |
| 45 | + |
| 46 | +```ts |
| 47 | +export interface StorageMethodsInterface { |
| 48 | + get: (key: string) => any; |
| 49 | + set: (key: string, value: any) => void; |
| 50 | + remove: (key: string) => void; |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +| Prop | Type | Default | Description | Required | |
| 55 | +|----------|----------------------------------------|-----------|--------------------------------------------------------|----------| |
| 56 | +| `get` | (key: string) => any | undefined | Get Method of Storage (gets Items from Storage) | Yes | |
| 57 | +| `set` | (key: string, value: any) => void | undefined | Set Method of Storage (saves/updates Items in Storage) | Yes | |
| 58 | +| `remove` | (key: string) => void | undefined | Remove Method of Storage (removes Items from Storage) | Yes | |
| 59 | + |
| 60 | + |
| 61 | +<br/> |
| 62 | + |
| 63 | +--- |
| 64 | + |
| 65 | +<br/> |
| 66 | + |
| 67 | + |
| 68 | +### `StateConfig` |
| 69 | + |
| 70 | +```ts |
| 71 | +export interface StateConfigInterface { |
| 72 | + key?: StateKey; |
| 73 | + dependents?: Array<Observer>; |
| 74 | + isPlaceholder?: boolean; |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +| Prop | Type | Default | Description | Required | |
| 79 | +|-----------------|--------------------|-----------|-----------------------------------------------------------------------------------------------------------|----------| |
| 80 | +| `key` | `string \| number` | undefined | Key/Name of State | No | |
| 81 | +| `dependents` | Observer[] | [] | Initial dependents of the State -> if State mutates, the dependents will be ingested into the Runtime too | No | |
| 82 | +| `isPlaceholder` | boolean | false | If State is a placeholder, to hold a reference (used internal) | No | |
| 83 | + |
| 84 | + |
| 85 | +<br/> |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | +<br/> |
| 90 | + |
| 91 | + |
| 92 | +### `CollectionConfig` |
| 93 | + |
| 94 | +```ts |
| 95 | +export type CollectionConfig<DataType = DefaultItem> = |
| 96 | +| CreateCollectionConfigInterface<DataType> |
| 97 | +| (( |
| 98 | +collection: Collection<DataType> |
| 99 | +) => CreateCollectionConfigInterface<DataType>); |
| 100 | +``` |
| 101 | +*[CreateCollectionConfigInterface](#createcollectionconfig) |
| 102 | + |
| 103 | +**There are two ways configuring the Collection:** |
| 104 | + |
| 105 | +1. The _Object_ way, where we can configure everything, but we are limited in the creation of Groups and Selectors, |
| 106 | + because here the Collection creates them for us, and for instance we can't pass initial Items to them. |
| 107 | + ```ts |
| 108 | + const Collection = App.createCollection({ |
| 109 | + key: 'dummyCollection', |
| 110 | + group: ["dummyGroup"] |
| 111 | + }) |
| 112 | + ``` |
| 113 | + |
| 114 | +2. The _Function_ way, where we can configure everything too, but here we are able to create the Groups and Selectors from scratch, |
| 115 | + and have more control over them. |
| 116 | + ```ts |
| 117 | + const Collection = App.createCollection((collection) => ({ |
| 118 | + key: 'dummyCollection', |
| 119 | + group: { |
| 120 | + dummyGroup: collection.Group(["item1", "item2"]) |
| 121 | + } |
| 122 | + })) |
| 123 | + ``` |
| 124 | + |
| 125 | + |
| 126 | +<br/> |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +<br/> |
| 131 | + |
| 132 | + |
| 133 | +### `CreateCollectionConfig` |
| 134 | + |
| 135 | +```ts |
| 136 | +export interface CreateCollectionConfigInterface<DataType = DefaultItem> { |
| 137 | + groups?: { [key: string]: Group<any> } | string[]; |
| 138 | + selectors?: { [key: string]: Selector<any> } | string[]; |
| 139 | + key?: CollectionKey; |
| 140 | + primaryKey?: string; |
| 141 | + defaultGroupKey?: GroupKey; |
| 142 | + initialData?: Array<DataType>; |
| 143 | +} |
| 144 | + |
| 145 | +``` |
| 146 | +| Prop | Type | Default | Description | Required | |
| 147 | +|-------------------|-------------------------------------------------|-----------|--------------------------------------------------------------------------------------------------------|----------| |
| 148 | +| `groups` | { [ key : string]: Group<any\> } \| string[] | [] | Initial Groups of Collection. Groups are used to represent multiple representations of the Collection. | No | |
| 149 | +| `selectors` | { [ key : string]: Selector<any\> } \| string[] | [] | Initial Selectors of Collection. Selectors are used to select one specific Item of the Collection. | No | |
| 150 | +| `key` | string \| number | undefined | Key/Name of Collection | No | |
| 151 | +| `primaryKey` | string | 'id' | Primary Key property of Item, used to identify Items in Collection. | No | |
| 152 | +| `defaultGroupKey` | GroupKey | 'default' | How the default Group, which represents the main representation of the Collection, is called. | No | |
| 153 | +| `initialData` | Array< DataType > | [] | Initial Data of Collection | No | |
| 154 | + |
| 155 | + |
| 156 | +<br/> |
| 157 | + |
| 158 | +--- |
| 159 | + |
| 160 | +<br/> |
| 161 | + |
| 162 | + |
| 163 | +### `CreateEventConfig` |
| 164 | + |
| 165 | +```ts |
| 166 | +export interface CreateEventConfigInterface { |
| 167 | + key?: EventKey; |
| 168 | + enabled?: boolean; |
| 169 | + maxUses?: number; |
| 170 | + delay?: number; |
| 171 | + overlap?: boolean; |
| 172 | + rerender?: boolean; |
| 173 | + dependents?: Array<Observer>; |
| 174 | +} |
| 175 | +``` |
| 176 | + |
| 177 | +| Prop | Type | Default | Description | Required | |
| 178 | +|--------------|------------------|-----------|-----------------------------------------------------------------------------------------------------------|----------| |
| 179 | +| `key` | string \| number | undefined | Key/Name of Event | No | |
| 180 | +| `enabled` | boolean | true | If Event is enabled and can be triggered | No | |
| 181 | +| `maxUses` | number | undefined | How often the Event can be triggered, by default infinite | No | |
| 182 | +| `delay` | number (in ms) | undefined | If the Event should have an trigger delay | No | |
| 183 | +| `overlap` | boolean | false | If a triggered Event can overlap another triggered Event from same Event Class | No | |
| 184 | +| `rerender` | boolean | false | If a Event trigger can rerender a Component (useEvent) | No | |
| 185 | +| `dependents` | Observer[] | [] | Initial dependents of the State -> if State mutates, the dependents will be ingested into the Runtime too | No | |
0 commit comments