Ionic using PounchDB fail - sqlite

I`m testing PounchDB for my new app and, i receive this error when try execute this code:
PouchDB.plugin(require('pouchdb-adapter-cordova'));
_db = new PouchDB('mydb.db', {adapter: 'cordova-sqlite'});
Erro received:
ReferenceError: Can't find variable: require
I follow instructions from: https://github.com/nolanlawson/pouchdb-adapter-cordova-sqlite
Using ionic 1.

You're using require without an associated package manager or module bundler. require is not native to JavaScript -- you have to include a library or package your app in order for this to work.
I suggest JSPM (http://jspm.io), since it works with SystemJS and supports the newest ES2015 module syntax. However, it also understands require.
Alternatively, you can use Browserify(http://browserify.org) to bundle your code (essentially Browserify packs everything into one file, which is great for production!). Webpack(https://webpack.github.io) is also a great option. Both of these will add a build step to your development workflow, so be aware of that (but you should have one anyway).

Related

Lightweight Rendering Pipeline error

I downloaded the lightweight rendering pipeline using Unity's package manager, but I cannot create a lightweight pipeline asset. When I try to create the asset, the console throws me:
Invalid generated unique path 'ProjectSettings/LightweightAsset.asset'
(input path
'LightweightAsset.asset')UnityEngine.Experimental.Rendering.LightweightPipeline.LightweightPipelineAsset:CreateLightweightPipeline()
I had a similar issue but it went away after I did the following:
Using the new package manager: Remove all rendering-related packages from the Unity project and then only add the Lightweight
Rendering Pipeline package. All dependencies (like the Shader Graph) were
added automatically and correctly after I did that.
Be sure to get the newest preview release (1.1.5-preview or newer). The 0.1-releases are too old.
If all else fails, try to follow the instructions and clone it directly from the Github repository: https://github.com/Unity-Technologies/ScriptableRenderPipeline

Meteor: jQuery is not defined

I am having a problem with using jQuery in my Meteor app. It is undefined.
When I look inside .meteor/versions, I can clearly see:
jquery#1.11.3_2
But when I type $ or jQuery in my Chrome console, I get undefined. Also, I cannot use external packages that use any jQuery; I get undefined is not a function exception.
Manually adding jQuery package by meteor add jquery did not solve the issue.
Any idea why this happens?
jQuery is inside the meteor core and defined as a dependency inside meteor-platform. So I never declare it as a a dependency. Meteor relies heavily on it, so it's unlikely to ever be removed. Unlike underscore, which they stated they will remove in a future release. Meteor always aliases $. So that should work. It can't be an issue with that specific version. I'm running the same without any issues. Here are some things you could try to debug:
Create a new project and check if JQ works
Check if an installed package is causing the problem (by removing them one by one)
Packages get loaded before your code, so that can't be the problem.

Meteor Testing Using Spies

I'm using Velocity with the mike:mocha framework and the chai assertions. Everything is working great, but when it comes time to do stubbing, mocking and spying, I've hit a bit of a roadblock. These aren't core features of mike:mocha or chai, so I found practicalmeteor:chai, which should/may have added spies.
My first stab at finding out whether this is true was to write the following code:
it 'calls update when both documents are present but different', ->
spies.create('log', console, 'log')
which gives me:
ReferenceError: spies is not defined
at packages/velocity:test-proxy/tests/mocha/server/charger_server_doc_spec.coffee:88:9
at wrappedFunc (packages/mike:mocha/server.js:200:1)
at runWithEnvironment (packages/mike:mocha/server.js:156:1)
That implies to me that I've misunderstood what practicalmeteor:chai provides, however, the code I showed in the first example is copied verbatim from the README.
Question: Any tips on getting this to work? Is it a load order issue? The code on Github shows spies and so on are implemented in this package. So I'm a bit stuck.
Thanks!
The package practicalmeteor:chai does not include the practicalmeteor:sinon package which is required to get the spies API included.
They are separate packages because you may not have to use spies when creating basic tests with chai.
If you look at the package.js file in the practicalmeteor:chai package, it does not include the sinon files.
So, just running meteor add practicalmeteor:sinon should solve your problem.

What is __meteor_bootstrap__?

I am just starting with Meteor and working on an existing project. I am running into an issue with one of the packages(observatory-apollo) that's has the following line:
__meteor_bootstrap__.app.use Observatory.logger #TLog.useragent
It is complaining that __meteor_bootstrap__.app is undefined.
What is __meteor_boostrap__ exactly? I can't seem to find a description of what it is but from threads, people seem to know how to use it. I can only see it defined in boot.js, but it doesn't really tell me much...
Meteor uses connect npm module under the hood for various reasons, to serve static files, for example. __meteor_bootstrap__.app was the reference to connect app instance.
Before it was __meteor_bootstrap__.app but it changed couple of releases ago and became WebApp.connectHandlers object and is part of WebApp package.
WebApp is a standard package of Meteor, core package for building webapps. You don't usually need to add explicitly as it is a dependency of standard-app-packages.
Example of usage the connectHandlers is to inject connect middlewares in the same way as you would use any connect middleware (or some express middlewares, express is built on top of connect):
WebApp.connectHandlers
.use(connect.query())
.use(this._config.requestParser(bodyParser))
You can look at meteor-router Atmosphere package and take it as an example: https://github.com/tmeasday/meteor-router/blob/master/lib/router_server.js
More about connect: https://npmjs.org/package/connect

Running meteor project on a newer version

Five months ago I created a project using meteor windows version 0.5.x, project works great on that version of meteor, but today, when I migrated to version 0.6.4.1 I had problems with the functionality of the project, three functions from model.js loss reference in client.js call (undefined functions).
Exception from Deps recompute: ReferenceError: displayName is not defined
(but, this function is defined in model.js)
I noticed, from browser console that every function of the model lose reference in client.js.
I tried to run the project using the command
meteor --release 0.5.x
but every try to run I get the error "Can't specify a release when running meteor from a checkout".
What would be the problem for undefined reference functions (in the release of newer version).
Meteor 0.6.x changed variable scoping across multiple files : each source file is encapsulated inside an anonymous function making its local var/function declarations visible only to the concerned file.
To enable exporting symbols and reference them in other files, you now have to use this syntax :
myVar=value;
// instead of
var myVar=value;
myFunc=function(){...};
// instead of
function myFunc(){...}
If you did something like
function displayName(){...}
in model.js, try replacing it with
displayName=function(){...};
I'm pretty sure it will do the trick.

Resources