x-cubed / event-store-client

JS client library for connecting to Event Store over TCP/IP
The Unlicense
71 stars 24 forks source link

Support for Angular 5 + Typescript client-side app ? #34

Closed SebLz closed 6 years ago

SebLz commented 6 years ago

Hello,

I've tried to use this library to connect angular 5 clients to an eventstore backend, unfortunately I'm running into multiple problems. I've installed the application using npm install event-store-client and inserted import * as EventStoreClient from "event-store-client"; at the top of test-es.ts - the TS file responsible for connecting to the EventStore server (based on the provided example.js file). After building the app with ng serve, I first had a first runtime error when loading the page that calls to test-es.ts: get http://localhost:4200/ClientMessageDtos.proto error 404 (not found) I solved this by manually deploying the proto file in .angular-cli.json Then I run into another runtime error:

ERROR TypeError: net.connect is not a function
    at new Connection (connection.js:49)

Therefore I was wondering if anyone had successfully managed to use this library in an Angular+typescript client-side application.

And btw, thanks for this very interesting library !

x-cubed commented 6 years ago

This library is intended for use from Node.js, and the net module is part of that. If you're using it client-side, you'll need to find a module that can provide that functionality for you. You probably need components on both the client and the server to get this working, as web browsers generally don't support raw TCP connections. This library is intended for server-side applications that need the performance benefits of the binary protocol.

Given your scenario, you'd be better off using the Event Store HTTP API directly from the client.

SebLz commented 6 years ago

Ok, thanks for your explanations. I also considered the http API but I don't really like the polling system. I think I will probably use SignalR then.