SplitmediaLabsLimited / xjs

XSplit JS Framework. Make plugins for XSplit Broadcaster, quickly and easily.
Other
39 stars 11 forks source link

3.0 experiment #248

Open dcefram opened 4 years ago

dcefram commented 4 years ago

Request For Comments (RFC):

It might make sense to check the proposed API on the temporary API Reference first: https://xjs.dcefram.now.sh/

Key differences between the current XJS Framework:

Now with that out of the way, I'd like to still get some feedback on this. I have a couple of implementations that I did that I wasn't fully convinced as the right or optimal way of doing it.

For example, I exposed a property named app which has 2 methods: getProperty and setProperty. The alternative was to simply use the base class (Xjs class) instead. Consider the following:

Current implementation:

import Xjs from 'xjs';

const xjs = new Xjs();

// Getting a view
const view = xjs.getView(0);
// Getting the current scene
const scene = await view.getCurrentScene();
const items = await scene.getItems();
items[0].getProperty(foo);
items[0].setProperty(foo, bar);

// Getting the app
const app = xjs.app;
app.getProperty(foo);
app.setProperty(foo, bar);

// Notice that for the view, we use a "getter", while for the app, it's just an instance property.

The idea that I didn't go for:

const xjs = new Xjs();

xjs.getAppProperty(foo);
xjs.setAppProperty(bar);

There might be more, like as to how I structured the app properties and item properties, etc. I'd like to request another set of professional eyes to look into the structure and API, and see if it's worth spending more time on :)

Oh, and does this work? Yes, it does. You can checkout the test app I did to ensure what I'm doing is not just an unusable experiment: https://github.com/dcefram/xjs-playground

You can also install this through npm:

npm i -S xjs-framework@3.0.0-alpha.3