@devvit/public-api
Table of contents
Namespaces
Enumerations
Classes
Type Aliases
- AllIconName
- AppInstall
- AppInstallDefinition
- AppUpgrade
- AppUpgradeDefinition
- BaseContext
- BaseField
- BlockElement
- BooleanField
- CancelJob
- CommentCreate
- CommentCreateDefinition
- CommentDelete
- CommentDeleteDefinition
- CommentReport
- CommentReportDefinition
- CommentSubmit
- CommentSubmitDefinition
- CommentUpdate
- CommentUpdateDefinition
- Configuration
- Context
- ContextAPIClients
- ContextDebugInfo
- CustomPostType
- Data
- Dispatch
- Form
- FormDefinition
- FormField
- FormFieldGroup
- FormFunction
- FormKey
- FormOnSubmitEvent
- FormOnSubmitEventHandler
- FormValues
- IconName
- JSONArray
- JSONObject
- JSONPrimitive
- JSONValue
- KVStore
- MediaAsset
- MediaPlugin
- MenuItem
- MenuItemLocation
- MenuItemOnPressEvent
- MenuItemUserType
- ModActionDefinition
- ModActionTrigger
- ModMailDefinition
- ModMailTrigger
- MultiTriggerDefinition
- NumberField
- OnTriggerRequest
- OnValidateHandler
- ParagraphField
- PluginSettings
- PostCreate
- PostCreateDefinition
- PostDelete
- PostDeleteDefinition
- PostFlairUpdate
- PostFlairUpdateDefinition
- PostReport
- PostReportDefinition
- PostSubmit
- PostSubmitDefinition
- PostUpdate
- PostUpdateDefinition
- RedisClient
- RunJob
- ScheduledCronJob
- ScheduledCronJobOptions
- ScheduledJob
- ScheduledJobEvent
- ScheduledJobHandler
- ScheduledJobOptions
- ScheduledJobType
- Scheduler
- SelectField
- SetOptions
- SetStateAction
- SettingScopeType
- SettingsClient
- SettingsFormField
- SettingsFormFieldGroup
- SettingsFormFieldValidatorEvent
- SettingsValues
- StateSetter
- StringField
- Toast
- TriggerContext
- TriggerDefinition
- TriggerEvent
- TriggerEventType
- TriggerOnEventHandler
- TxClientLike
- UIClient
- UploadMediaOptions
- UseChannelHook
- UseChannelResult
- UseFormHook
- UseIntervalHook
- UseIntervalResult
- UseStateHook
- UseStateResult
- ValidatedBooleanField
- ValidatedFormField
- ValidatedNumberField
- ValidatedParagraphField
- ValidatedSelectField
- ValidatedStringField
- ZMember
- ZRangeByScoreOptions
- ZRangeOptions
Variables
Functions
Type Aliases
AllIconName
Ƭ AllIconName: typeof ALL_ICON_NAMES[number]
AppInstall
Ƭ AppInstall: "AppInstall"
The event name for when your app is installed
AppInstallDefinition
Ƭ AppInstallDefinition: Object
Type declaration
| Name | Type |
|---|---|
event | AppInstall |
onEvent | TriggerOnEventHandler<protos.AppInstall> |
AppUpgrade
Ƭ AppUpgrade: "AppUpgrade"
The event name for when your app is upgraded
AppUpgradeDefinition
Ƭ AppUpgradeDefinition: Object
Type declaration
| Name | Type |
|---|---|
event | AppUpgrade |
onEvent | TriggerOnEventHandler<protos.AppUpgrade> |
BaseContext
Ƭ BaseContext: Object
Type declaration
| Name | Type | Description |
|---|---|---|
appAccountId | string | The ID of the current app's account |
commentId? | string | The ID of the current comment |
debug | ContextDebugInfo | More useful things, but probably not for the average developer |
postId? | string | The ID of the current post |
subredditId | string | The ID of the current subreddit |
userId? | string | The current user's ID if this event was triggered by a logged in user |
toJSON | () => Omit<BaseContext, "toJSON"> | Returns a JSON representation of the context |
BaseField
Ƭ BaseField<ValueType>: Object
Type parameters
| Name |
|---|
ValueType |
Type declaration
| Name | Type | Description |
|---|---|---|
defaultValue? | ValueType | The default value of the field |
disabled? | boolean | If true the field will be disabled |
helpText? | string | An optional help text that will be displayed below the field |
label | string | The label of the field. This will be displayed to the user |
name | string | The name of the field. This will be used as the key in the values object when the form is submitted |
required? | boolean | If true the field will be required and the user will not be able to submit the form without filling it in |
scope? | SettingScopeType | This indicates whether the field (setting) is an app level or install level setting. App setting values can be used by any installation. |
BlockElement
Ƭ BlockElement: Object
Type declaration
| Name | Type |
|---|---|
children | JSX.Children[] |
props | {} | undefined |
type | JSX.ComponentFunction | BlockComponent | CustomPostComponent | string | undefined |
BooleanField
Ƭ BooleanField: Prettify<Omit<BaseField<boolean>, "required"> & FieldConfig_Boolean & { type: "boolean" }>
A boolean field displayed as a toggle
CancelJob
Ƭ CancelJob: (jobId: string) => Promise<void>
Cancel a scheduled job
Type declaration
▸ (jobId): Promise<void>
Parameters
| Name | Type | Description |
|---|---|---|
jobId | string | The id of the job to cancel |
Returns
Promise<void>
CommentCreate
Ƭ CommentCreate: "CommentCreate"
The event name for when a comment is created, after safety delay
CommentCreateDefinition
Ƭ CommentCreateDefinition: Object
Type declaration
| Name | Type |
|---|---|
event | CommentCreate |
onEvent | TriggerOnEventHandler<protos.CommentCreate> |
CommentDelete
Ƭ CommentDelete: "CommentDelete"
The event name for when a comment is deleted
CommentDeleteDefinition
Ƭ CommentDeleteDefinition: Object
Type declaration
| Name | Type |
|---|---|
event | CommentDelete |
onEvent | TriggerOnEventHandler<protos.CommentDelete> |
CommentReport
Ƭ CommentReport: "CommentReport"
The event name for when a comment is reported
CommentReportDefinition
Ƭ CommentReportDefinition: Object
Type declaration
| Name | Type |
|---|---|
event | CommentReport |
onEvent | TriggerOnEventHandler<protos.CommentReport> |
CommentSubmit
Ƭ CommentSubmit: "CommentSubmit"
The event name for when a comment is submitted
CommentSubmitDefinition
Ƭ CommentSubmitDefinition: Object
Type declaration
| Name | Type |
|---|---|
event | CommentSubmit |
onEvent | TriggerOnEventHandler<protos.CommentSubmit> |
CommentUpdate
Ƭ CommentUpdate: "CommentUpdate"
The event name for when a comment is updated
CommentUpdateDefinition
Ƭ CommentUpdateDefinition: Object
Type declaration
| Name | Type |
|---|---|
event | CommentUpdate |
onEvent | TriggerOnEventHandler<protos.CommentUpdate> |
Configuration
Ƭ Configuration: Object
Type declaration
| Name | Type | Description |
|---|---|---|
http? | PluginSettings | boolean | Allows your app to use the HTTP/Fetch API |
kvStore? | PluginSettings | boolean | Allows your app to use the Key-Value Store |
media? | PluginSettings | boolean | Allows media uploads from apps |
modLog? | PluginSettings | boolean | Allows using ModLog API |
realtime? | PluginSettings | boolean | Allows your app to use the Realtime Plugin |
redditAPI? | PluginSettings | boolean | Allows your app to use the reddit API |
redis? | PluginSettings | boolean | Allows your app to use the Redis Plugin |
Context
Ƭ Context: ContextAPIClients & BaseContext
The current app context of the event or render
ContextAPIClients
Ƭ ContextAPIClients: Object
Type declaration
| Name | Type | Description |
|---|---|---|
assets | AssetsClient | A client for resolving static assets to public URLs |
cache | CacheHelper | The cache helper will let you cache JSON-able objects in your devvit apps for a limited amount of time. Under the covers, It's just Redis, so you do need to enable the redis feature. This provides a pattern for e.g. fetching remote calls without overwhelming someone's server. ts Devvit.configure({ redis: true, // Enable access to Redis }); /// ... let component = (context) => { let cached = context.cache(async () => { let rsp = await fetch("https://google.com") return rsp.body }, { key: "some-fetch", ttl: 10_000 // millis } doSomethingWith(cached); return <text>yay</text> } |
kvStore | KVStore | A client for the Key Value Store |
media | MediaPlugin | A client for media API |
modLog | ModLogClient | A client for the ModLog API |
realtime | RealtimeClient | A client for Realtime API |
reddit | RedditAPIClient | A client for the Reddit API |
redis | RedisClient | A client for the Redis API |
scheduler | Scheduler | A client for the Scheduler API |
settings | SettingsClient | A client for the Settings API |
ui | UIClient | A client for the User Interface API |
useChannel | UseChannelHook | A hook hor managing a realtime pubsub channel between Block renders. This is only available within a Block Component. |
useForm | UseFormHook | A hook for managing a form between Block renders. This is only available within a Block Component. |
useInterval | UseIntervalHook | A hook for managing a callback that runs on an interval between Block renders. This is only available within a Block Component. |
useState | (initialState: boolean | () => boolean | Promise<boolean>) => UseStateResult<boolean>(initialState: number | () => number | Promise<number>) => UseStateResult<number>(initialState: string | () => string | Promise<string>) => UseStateResult<string><S>(initialState: S | () => S | Promise<S>) => UseStateResult<S> | A hook for managing a state between Block renders. This is only available within a Block Component. Returns a tuple containing the current state and a function to update it. ts const [counter, setCounter] = useState(0); setCounter(1); // counter = 1 setCounter((count) => count + 1) // counter = 2 |
ContextDebugInfo
Ƭ ContextDebugInfo: Object
Type declaration
| Name | Type |
|---|---|
metadata | Metadata |
CustomPostType
Ƭ CustomPostType: Object
Type declaration
| Name | Type | Description |
|---|---|---|
description? | string | A description of the custom post type |
height? | RootHeight | The fixed height of the post, defaults to 'regular' |
name | string | The name of the custom post type |
render | CustomPostComponent | A function component that renders the custom post |
Data
Ƭ Data: Object
Index signature
▪ [key: string]: any
Dispatch
Ƭ Dispatch<A>: (value: A) => void
Type parameters
| Name |
|---|
A |
Type declaration
▸ (value): void
Parameters
| Name | Type |
|---|---|
value | A |
Returns
void
Form
Ƭ Form: Object
Type declaration
| Name | Type | Description |
|---|---|---|
acceptLabel? | string | An optional label for the submit button |
cancelLabel? | string | An optional label for the cancel button |
description? | string | An optional description for the form |
fields | FormField[] | The fields that will be displayed in the form |
title? | string | An optional title for the form |
FormDefinition
Ƭ FormDefinition: Object
Type declaration
| Name | Type | Description |
|---|---|---|
form | Form | FormFunction | A form or a function that returns a form |
onSubmit | FormOnSubmitEventHandler | A callback that will be invoked when the form is submitted |
FormField
Ƭ FormField: StringField | ParagraphField | NumberField | BooleanField | SelectField | FormFieldGroup
FormFieldGroup
Ƭ FormFieldGroup: Object
A grouping of fields
Type declaration
| Name | Type | Description |
|---|---|---|
fields | FormField[] | The fields that will be displayed in the group |
helpText? | string | An optional help text that will be displayed below the group |
label | string | The label of the group that will be displayed to the user |
type | "group" | - |
FormFunction
Ƭ FormFunction: (data: Data) => Form
A function that returns a form. You can use this to dynamically generate a form.
Example
const formKey = Devvit.createForm((data) => ({
fields: data.fields,
title: data.title,
}), callback);
...
ui.showForm(formKey, {
fields: [{ type: 'string', name: 'title', label: 'Title' }]
title: 'My dynamic form'
});
Type declaration
▸ (data): Form
Parameters
| Name | Type |
|---|---|
data | Data |
Returns
FormKey
Ƭ FormKey: `form.${number}` | `form.hook.${string}.${number}`
A unique key generated by Devvit.createForm or the useForm hook.
FormOnSubmitEvent
Ƭ FormOnSubmitEvent: Object
Type declaration
| Name | Type | Description |
|---|---|---|
values | FormValues | The form values that were submitted |
FormOnSubmitEventHandler
Ƭ FormOnSubmitEventHandler: (event: FormOnSubmitEvent, context: Context) => void | Promise<void>
Type declaration
▸ (event, context): void | Promise<void>
Parameters
| Name | Type |
|---|---|
event | FormOnSubmitEvent |
context | Context |
Returns
void | Promise<void>
FormValues
Ƭ FormValues: Data
IconName
Ƭ IconName: `${AllIconName}` | `${AllIconName}-outline` | `${AllIconName}-fill`
JSONArray
Ƭ JSONArray: JSONValue[]
JSONObject
Ƭ JSONObject: Object
Index signature
▪ [key: string]: JSONValue
JSONPrimitive
Ƭ JSONPrimitive: boolean | null | number | string
JSONValue
Ƭ JSONValue: JSONPrimitive | JSONArray | JSONObject
Any JSON type. Ie, a string, number, boolean, null, an array of these JSON types, or an object with JSON type values, recursively.
This type is often used to type-check attempts to serialize and deserialize classes, functions, and other JavaScript-only types that cannot be represented losslessly in plain JSON.
See
KVStore
Ƭ KVStore: Object
Type declaration
| Name | Type |
|---|---|
delete | (key: string) => Promise<void> |
get | <T>(key: string) => Promise<undefined | T> |
list | () => Promise<string[]> |
put | (key: string, value: JSONValue) => Promise<void> |
MediaAsset
Ƭ MediaAsset: Object
Type declaration
| Name | Type |
|---|---|
mediaId | string |
mediaUrl | string |
MediaPlugin
Ƭ MediaPlugin: Object
Type declaration
| Name | Type |
|---|---|
upload | (opts: UploadMediaOptions) => Promise<MediaAsset> |
MenuItem
Ƭ MenuItem: Object
Type declaration
| Name | Type | Description |
|---|---|---|
description? | string | An optional description for the menu item |
forUserType? | MenuItemUserType | MenuItemUserType[] | The user type(s) that the menu item should be displayed for |
label | string | The label of the menu item |
location | MenuItemLocation | MenuItemLocation[] | The location(s) where the menu item should be displayed |
postFilter? | MenuItemPostFilter | The filter that applies to post menu items. Has no effect on non-post actions |
onPress | (event: MenuItemOnPressEvent, context: Context) => void | Promise<void> | A function that is called when the menu item is pressed |
MenuItemLocation
Ƭ MenuItemLocation: "subreddit" | "post" | "comment"
MenuItemPostFilter
Ƭ MenuItemPostFilter: "currentApp"
MenuItemOnPressEvent
Ƭ MenuItemOnPressEvent: Object
Type declaration
| Name | Type | Description |
|---|---|---|
location | MenuItemLocation | The location where the menu item was pressed |
targetId | string | The ID of subreddit, post, or comment that the menu item was pressed; includes Thing ID prefix: - t1* - comment - t5* - subreddit - t3_ - post |
MenuItemUserType
Ƭ MenuItemUserType: "loggedOut" | "member" | "moderator"
ModActionDefinition
Ƭ ModActionDefinition: Object
Type declaration
| Name | Type |
|---|---|
event | ModActionTrigger |
onEvent | TriggerOnEventHandler<protos.ModAction> |
ModActionTrigger
Ƭ ModActionTrigger: "ModAction"
The event name for when a moderator action is recorded to a subreddit's modlog
ModMailDefinition
Ƭ ModMailDefinition: Object
Type declaration
| Name | Type |
|---|---|
event | ModMailTrigger |
onEvent | TriggerOnEventHandler<protos.ModMail> |
ModMailTrigger
Ƭ ModMailTrigger: "ModMail"
The event name for when a mod mail is sent/received
MultiTriggerDefinition
Ƭ MultiTriggerDefinition<Event>: Object
Type parameters
| Name | Type |
|---|---|
Event | extends TriggerEvent |
Type declaration
| Name | Type |
|---|---|
events | readonly Event[] |
onEvent | TriggerOnEventHandler<TriggerEventType[Event]> |
NumberField
Ƭ NumberField: Prettify<BaseField<number> & Omit<FieldConfig_Number, "min" | "max" | "step"> & { type: "number" }>
A number field
OnTriggerRequest
Ƭ OnTriggerRequest: protos.PostFlairUpdate | protos.PostSubmit | protos.PostCreate | protos.PostUpdate | protos.PostReport | protos.PostDelete | protos.CommentSubmit | protos.CommentCreate | protos.CommentUpdate | protos.CommentReport | protos.CommentDelete | protos.AppInstall | protos.AppUpgrade | protos.ModAction | protos.ModMail
OnValidateHandler
Ƭ OnValidateHandler<ValueType>: (event: SettingsFormFieldValidatorEvent<ValueType>, context: Context) => void | string | Promise<void | string>
Type parameters
| Name |
|---|
ValueType |
Type declaration
▸ (event, context): void | string | Promise<void | string>
Parameters
| Name | Type |
|---|---|
event | SettingsFormFieldValidatorEvent<ValueType> |
context | Context |
Returns
void | string | Promise<void | string>
ParagraphField
Ƭ ParagraphField: Prettify<BaseField<string> & Omit<FieldConfig_Paragraph, "maxCharacters"> & { type: "paragraph" }>
A paragraph or textarea field
PluginSettings
Ƭ PluginSettings: Object
Type declaration
| Name | Type | Description |
|---|---|---|
enabled | boolean | Whether the plugin is enabled |
PostCreate
Ƭ PostCreate: "PostCreate"
The event name for when a post is created, after safety delay
PostCreateDefinition
Ƭ PostCreateDefinition: Object
Type declaration
| Name | Type |
|---|---|
event | PostCreate |
onEvent | TriggerOnEventHandler<protos.PostCreate> |
PostDelete
Ƭ PostDelete: "PostDelete"
The event name for when a post is deleted
PostDeleteDefinition
Ƭ PostDeleteDefinition: Object
Type declaration
| Name | Type |
|---|---|
event | PostDelete |
onEvent | TriggerOnEventHandler<protos.PostDelete> |
PostFlairUpdate
Ƭ PostFlairUpdate: "PostFlairUpdate"
The event name for when the flair of a post is updated
PostFlairUpdateDefinition
Ƭ PostFlairUpdateDefinition: Object
Type declaration
| Name | Type |
|---|---|
event | PostFlairUpdate |
onEvent | TriggerOnEventHandler<protos.PostFlairUpdate> |
PostReport
Ƭ PostReport: "PostReport"
The event name for when a post is reported
PostReportDefinition
Ƭ PostReportDefinition: Object
Type declaration
| Name | Type |
|---|---|
event | PostReport |
onEvent | TriggerOnEventHandler<protos.PostReport> |
PostSubmit
Ƭ PostSubmit: "PostSubmit"
The event name for when a post is submitted
PostSubmitDefinition
Ƭ PostSubmitDefinition: Object
Type declaration
| Name | Type |
|---|---|
event | PostSubmit |
onEvent | TriggerOnEventHandler<protos.PostSubmit> |
PostUpdate
Ƭ PostUpdate: "PostUpdate"
The event name for when a post is updated
PostUpdateDefinition
Ƭ PostUpdateDefinition: Object
Type declaration
| Name | Type |
|---|---|
event | PostUpdate |
onEvent | TriggerOnEventHandler<protos.PostUpdate> |
RedisClient
Ƭ RedisClient: Object
Type declaration
| Name | Type | Description |
|---|---|---|
global | Omit<RedisClient, "global"> | Allows read/write operations to global keys in Redis Global redis enables apps to persist and access state across subreddit installations |
del | (...keys: string[]) => Promise<void> | Removes the specified keys. A key is ignored if it does not exist. https://redis.io/commands/del/ Arg keys |
expire | (key: string, seconds: number) => Promise<void> | Set a timeout on key. https://redis.io/commands/expire/ Arg key Arg seconds |
expireTime | (key: string) => Promise<number> | Returns the absolute Unix timestamp in seconds at which the given key will expire https://redis.io/commands/expiretime/ Arg key |
get | (key: string) => Promise<undefined | string> | Get the value of key. If the key does not exist the special value nil is returned. https://redis.io/commands/get/ Arg key |
getRange | (key: string, start: number, end: number) => Promise<string> | Returns the substring of the string value stored at key, determined by the offsets start and end (both are inclusive). https://redis.io/commands/getrange/ Arg key Arg start Arg end |
hdel | (key: string, fields: string[]) => Promise<number> | Removes the specified fields from the hash stored at key. https://redis.io/commands/hdel/ Arg key Arg fields |
hget | (key: string, field: string) => Promise<undefined | string> | Returns the value associated with field in the hash stored at key. https://redis.io/commands/hget Arg key Arg field |
hgetall | (key: string) => Promise<undefined | Record<string, string>> | Returns a map of fields and their values stored in the hash https://redis.io/commands/hgetall Arg key |
hincrby | (key: string, field: string, value: number) => Promise<number> | Increments the number stored at field in the hash stored at key by increment. https://redis.io/commands/hincrby/ Arg key Arg field Arg value |
hkeys | (key: string) => Promise<string[]> | Returns all field names in the hash stored at key. Arg key |
hscan | (key: string, cursor: number, pattern?: string, count?: number) => Promise<HScanResponse> | Iterates fields of Hash types and their associated values. Arg key Arg cursor Arg pattern Arg count |
hset | (key: string, fieldValues: { [field: string]: string; }) => Promise<number> | Sets the specified fields to their respective values in the hash stored at key. https://redis.io/commands/hset Arg key Arg fieldValues |
incrBy | (key: string, value: number) => Promise<number> | Increments the number stored at key by increment. https://redis.io/commands/incrby/ Arg key Arg value |
mget | (keys: string[]) => Promise<(null | string)[]> | Returns the values of all specified keys. https://redis.io/commands/mget/ Arg keys |
mset | (keyValues: { [key: string]: string; }) => Promise<void> | Sets the given keys to their respective values. https://redis.io/commands/mset/ Arg keyValues |
set | (key: string, value: string, options?: SetOptions) => Promise<string> | Set key to hold the string value. If key already holds a value, it is overwritten https://redis.io/commands/set/ Arg key Arg value Arg options |
setRange | (key: string, offset: number, value: string) => Promise<number> | Overwrites part of the string stored at key, starting at the specified offset, for the entire length of value. https://redis.io/commands/setrange/ Arg key Arg offset |
strlen | (key: string) => Promise<number> | Returns the length of the string value stored at key. An error is returned when key holds a non-string value. https://redis.io/commands/strlen/ Arg key |
type | (key: string) => Promise<string> | Returns the string representation of the type of the value stored at key https://redis.io/commands/type/ Arg key |
watch | (...keys: string[]) => Promise<TxClientLike> | Marks the given keys to be watched for conditional execution of a transaction. https://redis.io/commands/watch/ Arg keys - given keys to be watched |
zAdd | (key: string, ...members: ZMember[]) => Promise<number> | Adds all the specified members with the specified scores to the sorted set stored at key. https://redis.io/commands/zadd/ Arg key |
zCard | (key: string) => Promise<number> | Returns the cardinality (number of elements) of the sorted set stored at key. https://redis.io/commands/zcard/ Arg key |
zIncrBy | (key: string, member: string, value: number) => Promise<number> | Increments the score of member in the sorted set stored at key by value https://redis.io/commands/zincrby/ Arg key Arg member Arg value |
zRange | (key: string, start: string | number, stop: string | number, options?: ZRangeOptions) => Promise<{ member: string ; score: number }[]> | Returns the specified range of elements in the sorted set stored at key. https://redis.io/commands/zrange/ Arg key Arg start Arg stop Arg options |
zRank | (key: string, member: string) => Promise<number> | Returns the rank of member in the sorted set stored at key https://redis.io/commands/zrank/ Arg key Arg member |
zRem | (key: string, members: string[]) => Promise<number> | Removes the specified members from the sorted set stored at key. https://redis.io/commands/zrem/ Arg key Arg members |
zRemRangeByLex | (key: string, min: string, max: string) => Promise<number> | removes all elements in the sorted set stored at key between the lexicographical range specified by min and max https://redis.io/commands/zremrangebylex/ Arg key Arg min Arg max |
zRemRangeByRank | (key: string, start: number, stop: number) => Promise<number> | Removes all elements in the sorted set stored at key with rank between start and stop. https://redis.io/commands/zremrangebyrank/ Arg key Arg start Arg stop |
zRemRangeByScore | (key: string, min: number, max: number) => Promise<number> | Removes all elements in the sorted set stored at key with a score between min and max https://redis.io/commands/zremrangebyscore/ Arg key Arg min Arg max |
zScore | (key: string, member: string) => Promise<number> | Returns the score of member in the sorted set at key. https://redis.io/commands/zscore/ Arg key Arg member |
RunJob
Ƭ RunJob: (job: ScheduledJobOptions | ScheduledCronJobOptions) => Promise<string>
Schedule a new job to run at a specific time or on a cron schedule
Type declaration
▸ (job): Promise<string>
Parameters
| Name | Type | Description |
|---|---|---|
job | ScheduledJobOptions | ScheduledCronJobOptions | The job to schedule |
Returns
Promise<string>
ScheduledCronJob
Ƭ ScheduledCronJob: Object
Type declaration
| Name | Type | Description |
|---|---|---|
cron | string | The cron string of when this job should run |
data | Data | undefined | Additional data passed in by the scheduler client |
id | string | ID of the scheduled job. Use this with scheduler.cancelJob to cancel the job. |
name | string | The name of the scheduled job type |
ScheduledCronJobOptions
Ƭ ScheduledCronJobOptions: Object
Type declaration
| Name | Type | Description |
|---|---|---|
cron | string | The cron string of when this job should run |
data? | Data | Additional data passed in by the scheduler client |
name | string | The name of the scheduled job type |
ScheduledJob
Ƭ ScheduledJob: Object
Type declaration
| Name | Type | Description |
|---|---|---|
data | Data | undefined | Additional data passed in by the scheduler client |
id | string | ID of the scheduled job. Use this with scheduler.cancelJob to cancel the job. |
name | string | The name of the scheduled job type |
runAt | Date | The Date of when this job should run |
ScheduledJobEvent
Ƭ ScheduledJobEvent: Object
Type declaration
| Name | Type | Description |
|---|---|---|
data? | Data | Additional data passed in by the scheduler client |
name | string | The name of the scheduled job |
ScheduledJobHandler
Ƭ ScheduledJobHandler: (event: ScheduledJobEvent, context: Context) => void | Promise<void>
Type declaration
▸ (event, context): void | Promise<void>
Parameters
| Name | Type |
|---|---|
event | ScheduledJobEvent |
context | Context |
Returns
void | Promise<void>
ScheduledJobOptions
Ƭ ScheduledJobOptions: Object
Type declaration
| Name | Type | Description |
|---|---|---|
data? | Data | Additional data passed in by the scheduler client |
name | string | The name of the scheduled job type |
runAt | Date | The Date of when this job should run |
ScheduledJobType
Ƭ ScheduledJobType: Object
Type declaration
| Name | Type | Description |
|---|---|---|
name | string | The name of the scheduled job type |
onRun | ScheduledJobHandler | The function that will be called when the job is scheduled to run |
Scheduler
Ƭ Scheduler: Object
The Scheduler client lets you schedule new jobs or cancel existing jobs.
You must have the scheduler enabled in Devvit.configure to use this client.
Type declaration
| Name | Type | Description |
|---|---|---|
cancelJob | CancelJob | Cancel a scheduled job Param The id of the job to cancel |
listJobs | () => Promise<(ScheduledJob | ScheduledCronJob)[]> | Gets the list of all scheduled jobs. |
runJob | RunJob | Schedule a new job to run at a specific time or on a cron schedule Param The job to schedule |
SelectField
Ƭ SelectField: Prettify<BaseField<string[]> & Omit<FieldConfig_Selection, "choices" | "renderAsList" | "minSelections" | "maxSelections"> & { options: FieldConfig_Selection_Item[] ; type: "select" }>
A dropdown field that allows users to pick from a list of options
SetOptions
Ƭ SetOptions: Object
Type declaration
| Name | Type |
|---|---|
expiration? | Date |
nx? | boolean |
xx? | boolean |
SetStateAction
Ƭ SetStateAction<S>: S | (prevState: S) => S
Type parameters
| Name |
|---|
S |
SettingScopeType
Ƭ SettingScopeType: "installation" | "app"
SettingsClient
Ƭ SettingsClient: Object
The Settings API Client lets you retrieve the settings values for your app set by the installer.
Use this in conjunction with Devvit.addSettings.
Type declaration
| Name | Type |
|---|---|
get | <T>(name: string) => Promise<undefined | T> |
getAll | <T>() => Promise<T> |
SettingsFormField
Ƭ SettingsFormField: ValidatedStringField | ValidatedParagraphField | ValidatedNumberField | ValidatedBooleanField | ValidatedSelectField | SettingsFormFieldGroup
SettingsFormFieldGroup
Ƭ SettingsFormFieldGroup: Prettify<Omit<FormFieldGroup, "fields"> & { fields: SettingsFormField[] }>
SettingsFormFieldValidatorEvent
Ƭ SettingsFormFieldValidatorEvent<ValueType>: Object
Type parameters
| Name |
|---|
ValueType |
Type declaration
| Name | Type |
|---|---|
isEditing | boolean |
value | ValueType | undefined |
SettingsValues
Ƭ SettingsValues: Object
Index signature
▪ [key: string]: string | string[] | boolean | number | undefined
StateSetter
Ƭ StateSetter<S>: Dispatch<SetStateAction<S>>
Type parameters
| Name |
|---|
S |
StringField
Ƭ StringField: Prettify<BaseField<string> & Omit<FieldConfig_String, "minLength" | "maxLength"> & { isSecret?: boolean ; type: "string" }>
A text field
Toast
Ƭ Toast: Object
Type declaration
| Name | Type | Description |
|---|---|---|
appearance? | "neutral" | "success" | The appearance of the toast |
text | string | The message shown within the toast |
TriggerContext
Ƭ TriggerContext: Omit<Context, "ui">
TriggerDefinition
Ƭ TriggerDefinition: PostSubmitDefinition | PostCreateDefinition | PostUpdateDefinition | PostFlairUpdateDefinition | PostReportDefinition | PostDeleteDefinition | CommentSubmitDefinition | CommentCreateDefinition | CommentUpdateDefinition | CommentReportDefinition | CommentDeleteDefinition | AppInstallDefinition | AppUpgradeDefinition | ModActionDefinition | ModMailDefinition
TriggerEvent
Ƭ TriggerEvent: PostSubmit | PostCreate | PostUpdate | PostReport | PostDelete | PostFlairUpdate | CommentSubmit | CommentCreate | CommentUpdate | CommentReport | CommentDelete | AppInstall | AppUpgrade | ModActionTrigger | ModMailTrigger
TriggerEventType
Ƭ TriggerEventType: Object
Maps a TriggerEvent to a Protobuf message and type.
Type declaration
| Name | Type |
|---|---|
AppInstall | { type: "AppInstall" } & protos.AppInstall |
AppUpgrade | { type: "AppUpgrade" } & protos.AppUpgrade |
CommentCreate | { type: "CommentCreate" } & protos.CommentCreate |
CommentDelete | { type: "CommentDelete" } & protos.CommentDelete |
CommentReport | { type: "CommentReport" } & protos.CommentReport |
CommentSubmit | { type: "CommentSubmit" } & protos.CommentSubmit |
CommentUpdate | { type: "CommentUpdate" } & protos.CommentUpdate |
ModAction | { type: "ModAction" } & protos.ModAction |
ModMail | { type: "ModMail" } & protos.ModMail |
PostCreate | { type: "PostCreate" } & protos.PostCreate |
PostDelete | { type: "PostDelete" } & protos.PostDelete |
PostFlairUpdate | { type: "PostFlairUpdate" } & protos.PostFlairUpdate |
PostReport | { type: "PostReport" } & protos.PostReport |
PostSubmit | { type: "PostSubmit" } & protos.PostSubmit |
PostUpdate | { type: "PostUpdate" } & protos.PostUpdate |
TriggerOnEventHandler
Ƭ TriggerOnEventHandler<RequestType>: (event: RequestType, context: TriggerContext) => TriggerResult
Type parameters
| Name |
|---|
RequestType |
Type declaration
▸ (event, context): TriggerResult
Parameters
| Name | Type |
|---|---|
event | RequestType |
context | TriggerContext |
Returns
TriggerResult