playcanvas / playcanvas/pcui

Does the `binding` required, or API can be updated to only use `link` and `unlink`?

Open
#28 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
793
Forks
97
PR merge metrics
No merged PRs in 30d

Description

Current API design has few helpers for binding in different ways, and then element has link method. So Label to data currently is:

const label = new Label({
    binding: new BindingObserverToElement()
});
label.link(data, 'text');

And for bi-directional:

const textInput = new TextInput({
    binding: new BindingTwoWay()
});
textInput.link(data, 'text');
Question:

Is this is necessary to provide classes for binding?

Proposal:

Here is example of how it could simplify for users the data binding:

For read-only data:

const label = new Label();
label.link(data, 'text', { write: false });

For bi-directional (by default):

const textInput = new TextInput();
textInput.link(data, 'text');

For write only:

const textInput = new TextInput();
textInput.link(data, 'text', { read: false });

In JSX it will be:

<TextInput link={ data, path: 'text' } />

And to link attribute read and/or write property can be provided:

<TextInput link={ data, path: 'text', read: false } />

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing binding helper classes and the element link method described in the issue. Compare their current responsibilities with the proposed read and write options, then determine the required API behavior and JSX shape. Done means the project has a decided, documented direction with corresponding implementation scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
api, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.