Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
Force WebView Documentation for Server Side
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuyk committed Apr 4, 2023
1 parent 46a95d3 commit 9e819c0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 28 deletions.
29 changes: 1 addition & 28 deletions src/core/server/webview/index.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1 @@
import * as alt from 'alt-server';
import { WebViewEventNames } from '../../shared/enums/webViewEvents';

/**
* Emits an event directly to the client's WebView.
*
* @static
* @param {string} eventName
* @param {...any[]} args
*
*/
export function emit(player: alt.Player, eventName: string, ...args: any[]) {
player.emit(WebViewEventNames.ON_SERVER, eventName, ...args);
}

/**
* Closes all pages if no pages are specified.
* If pages are specified it only closes those specific pages.
*
* @param {Array<string>} [pages=[]]
*/
export function closePages(player: alt.Player, pages: Array<string> = []) {
if (typeof pages === 'undefined') {
pages = [];
}

player.emit(WebViewEventNames.CLOSE_PAGES, pages);
}
export { emit, closePages } from './utilities';
29 changes: 29 additions & 0 deletions src/core/server/webview/utilities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as alt from 'alt-server';
import { WebViewEventNames } from '../../shared/enums/webViewEvents';

/**
* Emits an event directly to the client's WebView.
*
* @static
* @param {string} eventName
* @param {...any[]} args
*
*/
export function emit(player: alt.Player, eventName: string, ...args: any[]) {
player.emit(WebViewEventNames.ON_SERVER, eventName, ...args);
}

/**
* Closes all pages if no pages are specified.
* If pages are specified it only closes those specific pages.
*
* @param {Array<string>} [pages=[]]
*/
export function closePages(player: alt.Player, pages: Array<string> = []) {
if (typeof pages === 'undefined') {
pages = [];
}

player.emit(WebViewEventNames.CLOSE_PAGES, pages);
}

0 comments on commit 9e819c0

Please sign in to comment.