Commit Graph

79 Commits

Author SHA1 Message Date
Scott Kyle 44a29d8dd4 Expose List and Results constructors into JS 2016-02-29 03:24:58 -08:00
Scott Kyle 97e6166597 Move browser JS shim under its own directory 2016-02-29 03:24:58 -08:00
Tim Anglade 7cc2f69736 Merge pull request #264 from realm/km-js-fixlicense
License update
2016-02-21 18:56:59 -08:00
Scott Kyle 2e3a3b5db8 Merge pull request #257 from realm/sk-schema-prop
The schema property should be directly on constructor
2016-02-18 16:27:47 -08:00
Karson Miller 5e9333b699 no message 2016-02-18 15:30:44 -08:00
Scott Kyle 5332131c14 Add sorted() method to List 2016-02-18 13:41:11 -08:00
Scott Kyle 05d84b23a2 Change sortedBy API as discussed
If provided an array, then each member can optionally be an array of [propName, reverse]
2016-02-18 12:47:18 -08:00
Scott Kyle 249bcd8f3f Change sortByProperty to return new Results
The method name changed to sortedBy to reflect that it returns a new Results object and to be more succinct. Also, the second optional argument instead reflects descending (or rather, reverse) since it's an anti-pattern to have an optional argument default to true in JS, and this also follows precedences set by other JS libraries and by Python's sorted function.
2016-02-18 11:58:39 -08:00
Scott Kyle b34e52b290 The schema property should be directly on constructor
The constructor is now also called with `this` set as the constructed object.

Fixes #232
2016-02-18 11:10:02 -08:00
Ari Lazier 6374a04ed4 chrome support for filtered 2016-02-17 20:27:10 -08:00
Scott Kyle 3e1889d342 Merge branch 'master' into sk-listview-merge
* master: (207 commits)
  Convert to using new React Native MainActivity template
  Create RealmReactPackage for our Android plugin
  Fix doc for Android
  NPM ignore react-native/android folder
  Skip building Android module under Xcode
  Skip building Android module for iOS tests
  gitignore Android downloads folder
  Update README with instructions to run on Android
  Use un-patched RN for Android by installing hook into JSC
  cleanup build system
  Use Realm in node_modules for ReactTests on Android
  Change Demo => ReactTests
  adding a 'publishAndroid' task to generate the AAR with prebuilt .so files
  Adjust POM_NAME
  Use consistent package naming
  Remove old Demo files
  Add copyright to JNI file
  Cleanup platform.hpp
  Make our Android module buildable as a dependency
  Add `npm test` command
  ...
2016-02-15 14:49:31 -08:00
Scott Kyle a6715d210d Ignore more things when publishing with NPM
Unfortunately some kind of NPM bug is making it ignore a top-level .npmignore file.
2016-01-22 16:43:53 -08:00
Scott Kyle eb4ac0000b Efficient React ListView for Realm collections
This component is fully backwards compatible with the original React ListView, but is compatible with Realm Results and List objects to use their snapshot functionality along with more efficiently checking if each row should update.
2016-01-21 11:41:38 -08:00
Scott Kyle bc77077b13 Merge branch 'sk-schema-api'
* sk-schema-api:
  Improve clarity of schema parsing and serialization
  Add test that checks schema validation
  Update README with new Schema API
  Cleanup some code and comments to make it consistent
  Convert tests to create objects with property objects
  Update example apps with new schema API
  Remove confusion between propTypes and objectTypes
  Simplify object schema info returned from RPC
  RPC now keeps object keys in the same order
  Change schema API to take properties as an object
  Add method to clear mutation listeners in RPC client
  Plug small leak from not releasing a JSStringRef
  Make RJSStringForValue use consistent exception style
  Improve error messages inside RJSUtil
2016-01-14 15:13:33 -08:00
Scott Kyle 7202994482 Add comments to explain checking for userAgent 2016-01-08 15:54:30 -08:00
Scott Kyle 334e646d7b Error message when RealmReact framework is missing
Fixes #190
2016-01-07 15:18:27 -08:00
Scott Kyle 15052985f1 Remove confusion between propTypes and objectTypes
The RPC layer now only speaks in objectTypes, since they don't always equate to propTypes. We were overloading the use of propTypes for no good purpose.
2016-01-05 13:53:54 -08:00
Scott Kyle 36ffc6c77c Simplify object schema info returned from RPC
Only the property names are needed.
2016-01-05 13:40:57 -08:00
Scott Kyle c928ab716e RPC now keeps object keys in the same order
Maintaining insertion order when passing objects through the RPC is essential to make the new schema API work.
2016-01-05 13:40:57 -08:00
Scott Kyle 358e5dacf3 Add method to clear mutation listeners in RPC client 2016-01-05 13:40:53 -08:00
Scott Kyle 381dbbe7ba Merge branch 'sk-npm'
* sk-npm:
  Add ability to publish NPM module to git
  Move RealmJS.mm to correct location
2016-01-05 13:25:20 -08:00
Scott Kyle 632f9d737e Add methods to create snapshot of List and Results
The Results class was updated to match the style of List and include a flag (m_live) that determines if it should sync updates. If an object in the static Results is deleted, then it will return null.
2015-12-30 16:53:26 -08:00
Scott Kyle 3da6b54df6 Add ability to publish NPM module to git
The top-level package.json explicitly includes the directories it needs (vendor/.npmignore cuts down the cruft). The publish-beta.sh script essentially uses `npm pack` to package up the NPM module and then push it into an orphaned `beta` branch.
2015-12-28 22:01:17 -08:00
Scott Kyle 4109c86343 Make Realm object properties enumerable 2015-12-08 03:26:57 -08:00
Scott Kyle be0c2a91ea Fix RPC client error after deleting objects
Specifically for objects with lists, since the mutation listener would fire on a list that no longer is attached. If during the mutation listener that error is thrown, then the listener will be removed and the error will not be propagated.
2015-12-01 14:05:33 -08:00
Ari Lazier 55851f6d99 fix for rpc constants and other pr feedback 2015-11-18 17:55:30 -08:00
Scott Kyle 7b115a934b ArrayBufferView objects now fully supported
Previously we were not accounting for the byte offsets and misunderstood how the Uint8Array constructor worked. The tests now confirm everything works as expected with multiple different typed arrays and slices of the data.
2015-11-17 13:32:32 -08:00
Scott Kyle 616f78ea07 Add support for data properties in RPC layer
The data is base64 encoded before being sent via the RPC.
2015-11-17 13:32:31 -08:00
Scott Kyle 336ef55c1f Remove uses of for-of loops in RPC modules
The React Native packager does not transform for-of loops, and minification step uses UglifyJS, which does not yet support ES6 syntax.

Fixes #120
2015-11-05 16:10:52 -08:00
Scott Kyle 7df2997ee7 Use a Set to store listener callbacks in JS 2015-11-03 02:41:52 -08:00
Scott Kyle 0b35564830 Merge pull request #107 from realm/sk-live-update-fixes
Ensure Lists and Results live-update in Chrome
2015-10-28 10:46:43 -07:00
Scott Kyle 46bee3c867 Add beta licenses to Chrome JS modules 2015-10-28 10:37:17 -07:00
Scott Kyle 0eb3b49970 Ensure Lists and Results live-update in Chrome
Results needed to live-update during a transaction (not just as the end), and Lists needed to update on deletions as well.
2015-10-28 10:21:32 -07:00
Ari Lazier ec87281cc1 don't convert undefined to null in rpc requests 2015-10-27 12:13:57 -07:00
Ari Lazier a1c4cd5702 pr fixes 2015-10-27 07:48:11 -07:00
Ari Lazier 6f41c3cf68 take notification name 2015-10-26 19:18:24 -07:00
Ari Lazier bb68e45250 support notifications in chrome 2015-10-26 16:49:46 -07:00
Scott Kyle d55d42da8d Add ESLint config for JS test files
This helps the editor catch simple syntax issues before finding out about them when running a test.
2015-10-21 15:20:44 -07:00
Scott Kyle 2e592bc101 Sprinkle some const inside ES6 JS code
React Native 0.13.0 fixes the bug we experienced by using const.
2015-10-21 13:57:34 -07:00
Scott Kyle 725e9855fe Update RPC JS to use originalXMLHttpRequest
React Native now leaves the original object accessible when it "polyfills" objects. So we check for that, but still have the previous logic in place in case they change their minds.
2015-10-21 13:57:34 -07:00
Scott Kyle 0055d0510c Make List objects work with Object.keys in Chrome
Rather than using Object.preventExtensions to throw exceptions when setting any out-of-bounds index, we must instead compromise by only throwing for the common cases, which are -1 and list.length. Having Object.keys() support is essential for List to work with React Native ListViewDataSource.

Resolves #80
2015-10-21 13:11:41 -07:00
Scott Kyle 34b84759c8 Fix crash when reloading app during Chrome debugging
Added a session ID, that actually tracks the Realm constructor in our RPC server's JS context. This conveniently let us remove the special casing for defaultPath as well as letting us call the Realm constructor with JSObjectCallAsConstructor.

Fixes #68
2015-10-20 15:10:52 -07:00
Scott Kyle 01dc3a85d9 Add comment about usage of preventExtensions 2015-10-20 00:52:38 -07:00
Scott Kyle f2c4e7882a Make RPC lists non-extensible
Assigning to non-existent index will throw an exception and all tests pass in Chrome!
2015-10-19 17:43:51 -07:00
Scott Kyle 85e2a26b42 Make RPC Results objects auto-resize 2015-10-19 17:28:20 -07:00
Scott Kyle 3439b4c455 Add getter/setter for defaultPath to RPC 2015-10-19 16:59:04 -07:00
Scott Kyle 03751c35b4 Handle passing dates through RPC 2015-10-19 16:46:56 -07:00
Scott Kyle b07aa72a55 Move all constants into a single JS file 2015-10-19 16:19:43 -07:00
Scott Kyle 57778ce878 Improve calling object methods through RPC 2015-10-19 16:15:38 -07:00
Scott Kyle d172b43535 Add path and schemaVersion getters to realm object 2015-10-19 15:46:28 -07:00