Skip to content

Create public API#40

Draft
ReinderVosDeWael wants to merge 8 commits into
mainfrom
feature/finalize-api
Draft

Create public API#40
ReinderVosDeWael wants to merge 8 commits into
mainfrom
feature/finalize-api

Conversation

@ReinderVosDeWael
Copy link
Copy Markdown
Contributor

@ReinderVosDeWael ReinderVosDeWael commented Sep 11, 2023

This draft PR is meant as a starting point to address #39. At present, it refactors the models to the set-up proposed by this issue. As there is no attribute type that allows public read-only but private writing, I've set the attributes to private but added a get object for read access.

I consider everything in this PR to be an early draft, so feel free to modify anything.

@ReinderVosDeWael ReinderVosDeWael self-assigned this Sep 11, 2023
@ReinderVosDeWael ReinderVosDeWael changed the title Feature/finalize-api Create public API Sep 11, 2023
Copy link
Copy Markdown
Contributor

@nx10 nx10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about using properties here, otherwise it looks good 👍

Comment thread src/models.ts
get(propertyName: "vertices"): Float32Array;
get(propertyName: "faces"): Uint32Array;
get(propertyName: "vertices" | "faces") {
return this[propertyName];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do these have to be properties? Why not either public or readonly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose this because I wanted it to be readonly, but readonly also prevents private writing. This was the workaround I found towards that end; would you just make them public?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah seems like it's a missing language feature microsoft/TypeScript#37487

I'm fine with whatever then. Probably I would prefer just obj.getIntensity() for auto complete convenience but do what you think is best.

Comment thread src/models.ts
get(propertyName: "colorMapName"): ColorInterpolateName;
get(propertyName: "colors"): Float32Array;
get(propertyName: "intensity" | "colorLimits" | "colorMapName" | "colors") {
return this[propertyName];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See same comment chain above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a method/attribute to access intensity

3 participants