Skip to content

Commit 403e575

Browse files
committed
Re-org and re-order
1 parent c16e744 commit 403e575

10 files changed

+40
-40
lines changed

examples/react-native/__tests__/ts/Models/index.ts renamed to examples/react-native/__tests__/RealmConfig.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// :snippet-start: create-realm-context
22
import {createRealmContext} from '@realm/react';
33
// Import all of your models.
4-
import Invoice from './Invoice';
5-
import Business from './Business';
4+
import Invoice from './ts/Models/Invoice';
5+
import Business from './ts/Models/Business';
66
// :remove-start:
7-
import Address from './Address';
8-
import Contact from './Contact';
7+
import Address from './ts/Models/Address';
8+
import Contact from './ts/Models/Contact';
99
// :remove-end:
1010

1111
export const RealmContext = createRealmContext({

examples/react-native/__tests__/ts/realm-database/configure-realm-local.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// :snippet-start: configure-realm
22
import React from 'react';
3-
import {RealmContext} from '../Models';
3+
import {RealmContext} from '../../RealmConfig';
44
// :remove-start:
55
import {render} from '@testing-library/react-native';
66
import {useApp} from '@realm/react';

examples/react-native/__tests__/ts/realm-database/configure-realm-multiple.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// :snippet-start: two-realm-contexts
22
import React from 'react';
33
import {AppProvider, UserProvider} from '@realm/react';
4-
import {RealmContext} from '../Models';
5-
import {SecondRealmContext} from '../Models';
4+
import {RealmContext} from '../../RealmConfig';
5+
import {SecondRealmContext} from '../../RealmConfig';
66
// :remove-start:
77
import {render} from '@testing-library/react-native';
88
import {useApp} from '@realm/react';

examples/react-native/__tests__/ts/realm-database/configure-realm-sync.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// :snippet-start: configure-realm-sync
22
import React from 'react';
33
import {AppProvider, UserProvider} from '@realm/react';
4-
import {RealmContext} from '../Models';
4+
import {RealmContext} from '../../RealmConfig';
55
// :remove-start:
66
import {render} from '@testing-library/react-native';
77
import {useApp} from '@realm/react';

source/examples/generated/react-native/ts/index.snippet.create-realm-context.ts renamed to source/examples/generated/react-native/js/RealmConfig.snippet.create-realm-context.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {createRealmContext} from '@realm/react';
22
// Import all of your models.
3-
import Invoice from './Invoice';
4-
import Business from './Business';
3+
import Invoice from './ts/Models/Invoice';
4+
import Business from './ts/Models/Business';
55

66
export const RealmContext = createRealmContext({
77
// Pass all of your models into the schema value.

source/examples/generated/react-native/ts/configure-realm-local.test.snippet.configure-realm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import {RealmContext} from '../Models';
2+
import {RealmContext} from '../../RealmConfig';
33

44
function AppWrapperLocal() {
55
const {RealmProvider} = RealmContext;

source/examples/generated/react-native/ts/configure-realm-multiple.test.snippet.two-realm-contexts.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import {AppProvider, UserProvider} from '@realm/react';
3-
import {RealmContext} from '../Models';
4-
import {SecondRealmContext} from '../Models';
3+
import {RealmContext} from '../../RealmConfig';
4+
import {SecondRealmContext} from '../../RealmConfig';
55

66
function TwoRealmsWrapper() {
77
const {RealmProvider: RealmProvider} = RealmContext;

source/examples/generated/react-native/ts/configure-realm-sync.test.snippet.configure-realm-sync.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import {AppProvider, UserProvider} from '@realm/react';
3-
import {RealmContext} from '../Models';
3+
import {RealmContext} from '../../RealmConfig';
44

55
function AppWrapperSync() {
66
const {RealmProvider} = RealmContext;

source/sdk/react-native/realm-database/configure-a-realm.txt

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,26 @@ The ``@realm/react`` library exposes realms in your application using
1414
`React Context objects <https://reactjs.org/docs/context.html>`__ and Provider
1515
components. You can access realms with React hooks.
1616

17-
To open a local realm, create a Context with the realm's configuration. The
17+
To configure and open a local realm, create a Context with the realm's configuration. The
1818
Context exports a ``RealmProvider`` component that exposes a configured realm.
1919
All child components of ``RealmProvider`` can access the realm using hooks.
2020

2121
To learn how to open a realm using Device Sync, refer to
2222
:ref:`Open a Synced Realm <react-native-open-a-synced-realm>`.
2323

24-
Create a Context Object with ``createRealmContext``
25-
---------------------------------------------------
24+
Create a Context Object
25+
-----------------------
2626

2727
By passing a :js-sdk:`Configuration <Realm.html#~Configuration>` object to
28-
``createRealmContext``, you can create a Context object that contains an open
28+
``createRealmContext()``, you create a Context object that contains an open
2929
realm and some hooks that give you access to the realm.
3030

3131
The following example creates and exports a Context object so that it can be
3232
used elsewhere.
3333

34-
.. literalinclude:: /examples/generated/react-native/ts/index.snippet.create-realm-context.ts
35-
:language: javascript
36-
:caption: Models/index.js
37-
38-
Configure a Realm with ``<RealmProvider>``
39-
------------------------------------------
40-
41-
``<RealmProvider>`` is a wrapper that exposes a Context with Realm Database to
42-
its child components. All child components inside ``<RealmProvider>`` have access
43-
to hooks that let you read, write, and update data. This is what a local-only
44-
realm wrapper might look like:
45-
46-
.. literalinclude:: /examples/generated/react-native/ts/configure-realm-local.test.snippet.configure-realm.tsx
34+
.. literalinclude:: /examples/generated/react-native/js/RealmConfig.snippet.create-realm-context.js
4735
:language: javascript
36+
:caption: RealmConfig.js
4837

4938
Open a Synced Realm
5039
~~~~~~~~~~~~~~~~~~~
@@ -59,28 +48,39 @@ To create a realm that runs entirely in memory without being written to a file,
5948
add ``inMemory: true`` to your :js-sdk:`Realm.Configuration
6049
<Realm.html#~Configuration>` object:
6150

62-
.. literalinclude:: /examples/generated/react-native/ts/index.snippet.in-memory-realm.ts
51+
.. literalinclude:: /examples/generated/react-native/js/RealmConfig.snippet.in-memory-realm.js
6352
:language: javascript
6453
:emphasize-lines: 3
6554

6655
In-memory realms may use disk space if memory is running low, but files created
6756
by an in-memory realm are deleted when you close the realm.
6857

69-
Open One or More Realms
70-
~~~~~~~~~~~~~~~~~~~~~~~
58+
Encrypt a Realm
59+
~~~~~~~~~~~~~~~
60+
61+
To encrypt a realm database file on disk, refer to
62+
:ref:`Encrypt a Realm <react-native-encrypt-a-realm>`.
63+
64+
Expose a Realm
65+
--------------
66+
67+
``<RealmProvider>`` is a wrapper that exposes a Context with Realm Database to
68+
its child components. All child components inside ``<RealmProvider>`` have access
69+
to hooks that let you read, write, and update data. This is what a local-only
70+
realm wrapper might look like:
71+
72+
.. literalinclude:: /examples/generated/react-native/ts/configure-realm-local.test.snippet.configure-realm.tsx
73+
:language: javascript
74+
75+
Expose More Than One Realm
76+
--------------------------
7177

7278
You can open more than one realm at a time by creating additional Contexts and
7379
``RealmProvider`` components.
7480

7581
.. literalinclude:: /examples/generated/react-native/ts/configure-realm-multiple.test.snippet.two-realm-contexts.tsx
7682
:language: javascript
7783

78-
Encrypt a Realm
79-
~~~~~~~~~~~~~~~
80-
81-
To encrypt a realm database file on disk, refer to
82-
:ref:`Encrypt a Realm <react-native-encrypt-a-realm>`.
83-
8484
Key Concept: Realm Files
8585
------------------------
8686

0 commit comments

Comments
 (0)