flecs
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

Flecs JavaScript client library (c) 2023, Sander Mertens, MIT license Thin wrapper around the Flecs REST API.

Resources: Flecs repository: https://github.com/SanderMertens/flecs API manual: https://www.flecs.dev/flecs/md_docs_RestApi.html API console: https://www.flecs.dev/explorer/console

Functions:

  • flecs.connect(host : string) Initializes the client library with the host address of the server. Example: flecs.connect("http://localhost:27750");

  • flecs.entity(path : string, params : object, recv : function, err : function) Retrieves an entity from the server. By default the response is formatted as a JavaScript object with the following properties: - parent : string - name : string - tags : array - pairs : object - components : object - type_info : object (optional) - alerts : array (optional)

    When the "raw" parameter is set to true, the response format is as described in the REST API manual. When the "raw" parameter is set to false or omitted the response will return labels instead of full paths for tags and components. To retrieve full paths, set the "full_paths" parameter to true.

    To poll for changes, set the "poll_interval" parameter to the number of milliseconds between requests. To abort polling, call abort() on the object returned by the function.

    Return: Object with the following members: - abort() : function Aborts the request. - url : string

    Example: flecs.entity("flecs.core.World", {}, (response) => { console.log(response); });

  • flecs.query(query, params, recv, err) Retrieves entities from the server that match the provided query. By default the response is formatted as a JavaScript object with the following properties: - type_info : object (optional) - entities : array - parent : string - name : string - tags : array - pairs : object - components : object - vars : object (optional)

    When the "raw" parameter is set to true, the response format is as described in the REST API manual. When the "raw" parameter is set to false or omitted the response will return labels instead of full paths for tags and components. To retrieve full paths, set the "full_paths" parameter to true.

    To poll for changes, set the "poll_interval" parameter to the number of milliseconds between requests. To abort polling, call abort() on the object returned by the function.

    Return: Object with the following members: - abort() : function Aborts the request. - url : string

    Example: flecs.query("Position, Velocity", {}, (response) => { console.log(response); });

  • flecs.query_name(query_name, params, recv, err) Same as flecs.query but for a named query.

    Return: Object with the following members: - abort() : function Aborts the request. - url : string

    Example: flecs.query_name("queries.my_query", {}, (response) => { console.log(response); });

Readme

Keywords

none

Package Sidebar

Install

npm i flecs

Weekly Downloads

1

Version

1.0.7

License

none

Unpacked Size

390 kB

Total Files

27

Last publish

Collaborators

  • cysidron