Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined fn app.model.call on client side #1

Closed
kolegm opened this issue May 30, 2016 · 5 comments
Closed

Undefined fn app.model.call on client side #1

kolegm opened this issue May 30, 2016 · 5 comments

Comments

@kolegm
Copy link
Owner

kolegm commented May 30, 2016

Please, help to resolve an issue: Undefined fn app.model.call on the client side

There is a function on the server side to create a store

`function store(derby, publicDir) {
var db = shareDbMongo(process.env.MONGO_URL + '?auto_reconnect=true', {
safe: true
});

derby.use(require('racer-bundle'));
derby.use(require('racer-rpc'));

var redis = require('redis-url');
var pubsub = require('sharedb-redis-pubsub')({ client: redis.connect(), observer: redis.connect() });

var store = derby.createBackend({ db: db, pubsub: pubsub });

store.rpc.on('test-rpc', function (params, callback) { /* some handler here */
callback(null, true);
});

return store;
}`

Call RPC-event on the client side
app.model.call('test-rpc, function (error, result) { });

When call it above, there is an error:
**Reason: app.model.call is not a function**

What has been done wrong?

I tried to repeat the logic you recommend: https://github.com/BBWeb/racer-rpc

@cjblomqvist
Copy link
Collaborator

You need to ensure you run derby.use(require('racer-rpc')) on the client-side as well. My suggestion is you put it at your root app file (the same file where you run derby.createApp()). Make sure to run it before derby.createApp(), otherwise, it won't work.

Let me know how your results.

@kolegm
Copy link
Owner Author

kolegm commented May 30, 2016

Thanks, it works!

And now, i have the next error: TypeError: args is undefined

at function, when unshift has been called

here
https://github.com/BBWeb/racer-rpc/blob/master/lib/index.js#L25

@cjblomqvist
Copy link
Collaborator

That might actually be a bug. Try returning something from your callback server side and see if it works.

In order for me to fix the issue it would be nice if you could paste both your client side call and your server side call here and I'll take a deeper look.

@kolegm
Copy link
Owner Author

kolegm commented Jun 1, 2016

I want to express my gratitude for help in solving my problem.
Debugging process showed that on my side were errors that successfully corrected.

So, the module racer-rpc works fine and response sends to the event producer (app.model.call)

Thanks for helping!

@kolegm kolegm closed this as completed Jun 1, 2016
@cjblomqvist
Copy link
Collaborator

Happy to help and happy that someone has use for the library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants