Skip to content

[Bridge] is it possible to get JavaScriptCore's JSContext somehow? #1618

@plandem

Description

@plandem

Why do i need it? Sometimes i just want to use javascript directly and don't create wrappers to emit events to/from JS to get values.

class SimpleApp extends React.Component {
    render() {
        return (
...view
        )
    }

    validate(data) {
        return -100;
    }
}

For example, i would like to get value from 'SimpleApp.prototype.validate'. Just want to call it directly.

In my case, i have one bundle with visuals and some functions that has no any connection to visual part. Right now we have only:

React.AppRegistry.registerRunnable('validate', function(data) { return -100; });

and call it from objective-c:

[_bridge enqueueJSCall:@"AppRegistry.runApplication" args:@[@"validate", @[@2, @2]]]

But current implementation does not allow to get value from js. So my question again - is it possible to get JSContext to do next:

JSValue *validator = context[@"SimpleApp.prototype.validate"];
JSValue *result = [validator callWithArguments:@[@5] ];

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions