jaystack / jaydata

Notice: this library isn't maintained anymore
http://jaydata.org
GNU General Public License v2.0
352 stars 94 forks source link

Jaydata and requirejs #248

Closed genusP closed 8 years ago

genusP commented 8 years ago

I load jaydata use requirejs.

requirejs.config({
    baseUrl:"/Scripts/",
    paths: {
        .......
        "jaydata/core": "jaydata/jaydata",
        "jaydatacontext": "../jaydatacontext"
    }
});

Context defenitions generated jaysvcutil with option -b. In my module use contex for get data:

///<reference path="./jaydatacontext.d.ts"/>
import { type, factory, context } from "JayDataContext";

class AddOrderViewModel {
    constructor() {
        this.getCatalog("ConsultLineOrderType_;ljiky").then(d => ....);
    }

    getCatalog(catalogName: string) {
        return context.SimpleCatalog
            .filter(function (it) { return it.CatalogName == this.cn }, { cn: catalogName })
                .map(it => { return { Id: it.Id, Name: it.Value } })
            .toArray();
    }

When execute this code in console pinted

odatajs-4.0.0.js:8097 deferred
odatajs-4.0.0.js:8097 utils
odatajs-4.0.0.js:8097 xml
odatajs-4.0.0.js:8097 odata
odatajs-4.0.0.js:8097 odatautils
odatajs-4.0.0.js:8097 handler
odatajs-4.0.0.js:8097 metadata
odatajs-4.0.0.js:8097 net
odatajs-4.0.0.js:8097 json
odatajs-4.0.0.js:8097 batch
odatajs-4.0.0.js:8097 store
odatajs-4.0.0.js:8097 dom
odatajs-4.0.0.js:8097 indexeddb
odatajs-4.0.0.js:6071 'webkitIndexedDB' is deprecated. Please use 'indexedDB' instead.
odatajs-4.0.0.js:8097 memory
odatajs-4.0.0.js:8097 cache
odatajs-4.0.0.js:8097 source
jaydata.js:9870 @@@@ undefined
jaydata.js:9870 @@@@ undefined
jaydata.js:9870 @@@@ undefined
jaydata.js:9870 @@@@ undefined
jaydata.js:9870 @@@@ undefined
jaydata.js:9870 @@@@ undefined
jaydata.js:9870 @@@@ undefined
jaydata.js:9870 @@@@ undefined
jaydata.js:7821 Provider fallback failed!require.21._initializeJayData2.default.defaultErrorCallback @ jaydata.js:7821error @ jaydata.js:11292r @ jaydata.js:4348require.9.PromiseHandler.createCallback.extend.error @ jaydata.js:4241_successInitProvider @ jaydata.js:11758require.45._index2.default.Class.define.constructor.storageProviderCfg._successInitProvider @ jaydata.js:11216r @ jaydata.js:4348error @ jaydata.js:11260r @ jaydata.js:4348(anonymous function) @ jaydata.js:21738watcher @ jaydata.js:21805
2jaydata.js:4315 Provider fallback failed!require.10.PromiseHandlerBase.defaultErrorCallback @ jaydata.js:4315r @ jaydata.js:4348require.9.PromiseHandler.createCallback.extend.error @ jaydata.js:4241_successInitProvider @ jaydata.js:11758require.45._index2.default.Class.define.constructor.storageProviderCfg._successInitProvider @ jaydata.js:11216r @ jaydata.js:4348error @ jaydata.js:11260r @ jaydata.js:4348(anonymous function) @ jaydata.js:21738watcher @ jaydata.js:21805
jaydata.js:4226 Uncaught (in promise) Provider fallback failed!require.9._super.PromiseHandler.deferred.reject @ jaydata.js:4226require.21._initializeJayData2.default.defaultErrorCallback @ jaydata.js:7822error @ jaydata.js:11292r @ jaydata.js:4348require.9.PromiseHandler.createCallback.extend.error @ jaydata.js:4241_successInitProvider @ jaydata.js:11758require.45._index2.default.Class.define.constructor.storageProviderCfg._successInitProvider @ jaydata.js:11216r @ jaydata.js:4348error @ jaydata.js:11260r @ jaydata.js:4348(anonymous function) @ jaydata.js:21738watcher @ jaydata.js:21805
undefined:1 Uncaught (in promise) Provider fallback failed!
undefined:1 Uncaught (in promise) Provider fallback failed!

In Network tab seen loading oDataProvider.js. What am I doing wrong?

lazarv commented 8 years ago

You can find a TypeScript with RequireJS use case in jaydata-odata-example.

genusP commented 8 years ago

Thanks. Needed to add

///<amd-dependency path="jaydata/odata" name="$data" />