Skip to content

JavaScript functions, when passed to Objective-C as blocks, will now round-trip back to JavaScript, as the initial function object.#234

Merged
jasssonpet merged 1 commit intomasterfrom
roundtrip-block-functions
Aug 18, 2015
Merged

JavaScript functions, when passed to Objective-C as blocks, will now round-trip back to JavaScript, as the initial function object.#234
jasssonpet merged 1 commit intomasterfrom
roundtrip-block-functions

Conversation

@PanayotCankov
Copy link
Copy Markdown
Contributor

No description provided.

@PanayotCankov PanayotCankov self-assigned this Jul 21, 2015
@PanayotCankov PanayotCankov added this to the 1.3.0 (Under Review) milestone Jul 21, 2015
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.

You can put the assignment in the if statement to reduce its scope.

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.

Moved it.

@ns-bot
Copy link
Copy Markdown

ns-bot commented Jul 21, 2015

1 similar comment
@ns-bot
Copy link
Copy Markdown

ns-bot commented Jul 21, 2015

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.

I would suggest to move this to TNSObjCTypes.m where we have tests like:

  • methodWithNSDate
  • methodWithNSArray
  • methodWithNSDictionary
  • methodWithNSData

which test the same thing (that the returned object is the same). You can make the methodWithSimpleBlock return the block.

Also removing the property from the header won't make the test fail, imo JS properties are a bit brittle.

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.

imo JS is brittle.

FTFY 😀

We can add an expectation that the block property exists with the in operator, but what you've touched upon is a problem everywhere, not just in this test.

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.

That's why we try to avoid accessing native properties in our tests.

@fealebenpae
Copy link
Copy Markdown
Contributor

run ci

@ns-bot
Copy link
Copy Markdown

ns-bot commented Jul 31, 2015

@fealebenpae
Copy link
Copy Markdown
Contributor

The build currently fails with:
src/NativeScript/ObjC/Block/ObjCBlockType.mm:78:28: error: cannot cast from type 'id' to pointer type 'NativeScript::JSBlock *'
reinterpret_cast should fix it.

@jasssonpet jasssonpet force-pushed the roundtrip-block-functions branch 2 times, most recently from ebc03b0 to eebe49c Compare August 18, 2015 11:29
…roundtrip back to JavaScript, as the initial function object.
@jasssonpet jasssonpet force-pushed the roundtrip-block-functions branch from eebe49c to f940cdd Compare August 18, 2015 11:52
jasssonpet added a commit that referenced this pull request Aug 18, 2015
JavaScript functions, when passed to Objective-C as blocks, will now round-trip back to JavaScript, as the initial function object.
@jasssonpet jasssonpet merged commit 11b0f4e into master Aug 18, 2015
@jasssonpet jasssonpet deleted the roundtrip-block-functions branch August 18, 2015 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants