From 334e646d7b42e742d8a4ad42c60bc7609c746e5b Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Thu, 7 Jan 2016 15:18:27 -0800 Subject: [PATCH 1/2] Error message when RealmReact framework is missing Fixes #190 --- lib/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 46ad49c6..f8cde9e4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -6,6 +6,8 @@ if (typeof Realm != 'undefined') { module.exports = Realm; // eslint-disable-line no-undef -} else { +} else if (navigator.userAgent) { module.exports = require('./realm'); +} else { + throw new Error('Missing Realm constructor - please ensure RealmReact framework is included!'); } From 7202994482172af071dad98d622160e237a132e9 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Fri, 8 Jan 2016 15:54:30 -0800 Subject: [PATCH 2/2] Add comments to explain checking for userAgent --- lib/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/index.js b/lib/index.js index f8cde9e4..8caaa960 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,8 +5,10 @@ 'use strict'; if (typeof Realm != 'undefined') { + // The global Realm constructor should be available on device (using JavaScriptCore). module.exports = Realm; // eslint-disable-line no-undef } else if (navigator.userAgent) { + // The userAgent will be defined when running in a browser (such as Chrome debugging mode). module.exports = require('./realm'); } else { throw new Error('Missing Realm constructor - please ensure RealmReact framework is included!');