-
Can I expose a Class to Javascript, but only a couple members/methods? For example: [Export(DefaultMembersHidden = true)]
public class Test {
[Export]
public int thisIsVisible = 1;
public string thisIsNotVisible = "This should not be visible";
public void ThisShouldAlsoBeInvisibe() {
throw new Exception("Oh no! This shouldn't be able to be called from Javascript!");
} // Procedure //
[Export]
public void ThisIsVisible() {
Console.WriteLine($"Woohoo! {thisIsVisible}");
} // Procedure //
} // Class // |
Beta Was this translation helpful? Give feedback.
Answered by
ackava
Mar 22, 2023
Replies: 1 comment 1 reply
-
If class is derived from https://github.com/yantrajs/yantra/blob/main/YantraJS.Core.Tests/ClrObjects/CustomObject.cs |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ackava
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If class is derived from
JavaScriptObject
, only members exposed withJSExport
attributes are exposed to JavaScript.https://github.com/yantrajs/yantra/blob/main/YantraJS.Core.Tests/ClrObjects/CustomObject.cs