pubkey / rxdb

A fast, local first, reactive Database for JavaScript Applications https://rxdb.info/
https://rxdb.info/
Apache License 2.0
21.37k stars 1.04k forks source link

can't run react-native example #159

Closed iwater closed 7 years ago

iwater commented 7 years ago

after the steps from here https://github.com/pubkey/rxdb/tree/master/examples/react-native use yarn instead of npm

simulator screen shot 2017 5 10 1 53 05

pubkey commented 7 years ago

Is this a yarn-specific problem or does it also not run with npm? I know it's unlikely that yarn is the evil, but could you test it for me?

iwater commented 7 years ago

npm got this error simulator screen shot 2017 5 10 11 36 22

pubkey commented 7 years ago

@iwater can you retry this with the latest version 4.0.1 ? It's possible that this works now.

iwater commented 7 years ago

retry with the latest version 4.0.2, got that same error

pubkey commented 7 years ago

Hi @iwater Can you describe your setup so that I can reproduce this? NodeVersion, OS-type, npm-version etc..

pubkey commented 7 years ago

The error comes with ios and i dont have or will have any apple-device to reproduce. It also looks like the error is a problem with the react-native build, not with rxdb itself.

So I'm closing this for now with a wontfix-label. Please reopen if you know how to fix this.

iwater commented 7 years ago

I just tried the latest example by rxdb commit use these steps from README

follow installation instructions to setup your react-native environment
clone the whole RxDB-repo
go into project cd rxdb
run npm install
go to this folder cd examples/react-native
run npm install
run react-native run-ios or react-native run-android

test env: NodeVersion: 8.1.0, OS-type: macOS 10.12.5, npm-version: 5.0.3

first start got this error simulator screen shot 2017 6 12 8 32 29

after npm install util and restart got this error simulator screen shot 2017 6 12 8 39 40

this unhandled promise point to util.validateCouchDBString which got a undefined argument

iwater commented 7 years ago

I dig the source find that

create function in index.js accept four arguments in comment and direct call RxDatabase exported create function, but that function accept a object argument wrap that four arguments and in react-native example code just call with four plain arguments, so that util.validateCouchDBString failed

code in example

RxDB.create('heroesReactDataBase1', 'asyncstorage', 'myLongAndStupidPassword', true).then((db) => {

code in index.js

/**
 * create a database
 * @param  {string} prefix as databaseName for the storage (this can be the foldername)
 * @param  {Object} storageEngine any leveldown instance
 * @param  {String} password if the database contains encrypted fields
 * @param  {boolean} multiInstance if true, multiInstance-handling will be done
 * @return {Promise<Database>}
 */
export async function create(args) {
    return RxDatabase.create(args);
}

code in RxDatabase.js

export async function create({
    name,
    adapter,
    password,
    multiInstance = true
}) {
    util.validateCouchDBString(name);   // promise reject
iwater commented 7 years ago

and in the example database name is heroesReactDataBase1, but in util check regex is

const regStr = '^[a-z][a-z0-9]*$';

mean it should be lowercase for whole string

iwater commented 7 years ago

and heroSchema in example is missing version as required

iwater commented 7 years ago

201 I made a pull request for up

BTW, because react-native have it's es6 compile process, maybe It should be better not publish .babelrc to npm registry (because that not compatible with react-native compile env, maybe not compatible others too), and referer rxdb with

import * as RxDB from 'rxdb/src/';

instead of

import * as RxDB from 'rxdb';

to let react-native compile rxdb source for it's env

pubkey commented 7 years ago

Thank you for the PR!

I added babelrc to gitignore since redux and other libs also do not publish them because of webpack-build-fails.

What is the benefit of using rxdb/src/? I thought without babelrc, the react-native-build would just not compile the module by itself and use the path given in the package.json. Or am I wrong?

pubkey commented 7 years ago

closing this since the original issue seems to be solved.