Giter Site home page Giter Site logo

Thanks a billion! about cyclejs-examples HOT 12 CLOSED

jessep avatar jessep commented on May 25, 2024
Thanks a billion!

from cyclejs-examples.

Comments (12)

jessep avatar jessep commented on May 25, 2024

Okay, mind blown: https://github.com/ivan-kleshnin/cyclejs-examples/blob/master/2.03-timer-stopwatch/scripts/app.js#L62

from cyclejs-examples.

ivan-kleshnin avatar ivan-kleshnin commented on May 25, 2024

Yes! Not my idea in any way but I'm glad you appreciated it as much as me.
This state is just a reduce over time approach is one of the most beautiful things
in programming I ever saw.

Imperative: how value is constructed from other values.
Declarative: what is Value in terms of other Values.
Explicit wins over Implicit in the first round!

Interactive: how value changes over time.
Reactive: what is Now in terms of the Past.
Explicit wins over implicit in the second round!

I actually think RxJS is a bit overcomplicated to what it could (should) be.
We will see more and better tries in the future.
But the direction looks correct at last, and knowledge we get now should be useful and portable.

from cyclejs-examples.

chasm avatar chasm commented on May 25, 2024

I second the comments above. This is some jaw-droppingly beautiful code. More examples would be delightful. It's easy to see how to use it for trivial apps, quite a bit more difficult to see how a large, complex, enterprise application would be organized.

from cyclejs-examples.

ivan-kleshnin avatar ivan-kleshnin commented on May 25, 2024

Thank you. You can also check https://github.com/ivan-kleshnin/tetris-cyclejs for an example, unfortunately, in early stage, of a game, written in CycleJS. On the other hand, maybe it will be even easier to understand in this state.

Yes, I'm going to add more examples. There was more but I had to remove them because multiple changes in CycleJS API make them outdated and I couldn't find enough time to update everything 😞 And I also have more questions than answers πŸ˜‰

I also wanted to ask you guys about my documentation.
Was it helpful or code was just enough for you?

from cyclejs-examples.

chasm avatar chasm commented on May 25, 2024

Excellent. Thanks!

The documentation is not bad. Of course, there can always be more, but I had no trouble understanding what is happening.

What would be helpful is more examples and answers to the following questions:

  1. How would one do authentication using cycle.js?
  2. Is it possible to treat the connection between client and server as a stream and to loop the back end in? Everything I've seen so far works entirely in the browser.
  3. How does persistence work? Even if it's just localStorage. Most of the apps I build (OK, all of them) require persisting state between visits and also distinguishing between authenticated and unauthenticated users (and perhaps authorized and unauthorized as well). Is there an FRP way to do this? I assume that there must be.

I'll keep learning and will be happy to post my own examples if/when I get to that point. (I will.)

from cyclejs-examples.

chasm avatar chasm commented on May 25, 2024

Also, it's your use of JSX and ramda that sold me on cycle.js. I can't imagine using it without them. So thanks for that.

from cyclejs-examples.

ivan-kleshnin avatar ivan-kleshnin commented on May 25, 2024

@chasm your questions are straight to the point.

How would one do authentication using cycle.js?

Is it possible to treat the connection between client and server as a stream and to loop the back end in? Everything I've seen so far works entirely in the browser.

How does persistence work? Even if it's just localStorage. Most of the apps I build (OK, all of them) require persisting state between visits and also distinguishing between authenticated and unauthenticated users (and perhaps authorized and unauthorized as well). Is there an FRP way to do this? I assume that there must be.

CycleJS team is about to finish new "Driver" concept which should address all this questions.
Code is in a "prerelease" stage, then documentation should follow.
So all we can do now is to wait a bit until it will be done.

From what I'm aware of right now, "drivers" will cover both Local Storage and HTTP request handling.
In older Cycle API(s) there were things called "DataSource" and "DataSink". So, basically we'll get the possibility to emit desired side effects as all this AJAX and LocalStorage writes are side-effects.
Initial reads are also a side-effects, just in the opposite direction.

Even without drivers Local Storage usage should be pretty simple and look like:

// READS
let observable$ = Observable.from(localStorage.read()); // pseudo-code

// WRITES
observable$.subscribe(v => {
  localStorage.write(v); // pseudo-code
});

AJAX is much harder (yet possible) to done right because we want to perform optimistic updates, retries, handle network disconnects etc.

So, addressing you questions directly, its

Drivers -> Persistence -> AJAX -> Authentication

order and I hope all this points will be available soon.

Also, it's your use of JSX and Ramda that sold me on CycleJS. I can't imagine using it without them. So thanks for that.

Thank you for the answers too!

from cyclejs-examples.

chasm avatar chasm commented on May 25, 2024

Outstanding. This is excellent. I will try to be patient but I'm very excited about this.

I get it on AJAX, etc. I hand't even thought about disconnects.

Is there a timeline or even a ballpark figure? I'm going to be free to start work on a learning management system (LMS) hopefully in August or September, and I'd like to work with cycle.js (as it matures).

from cyclejs-examples.

ivan-kleshnin avatar ivan-kleshnin commented on May 25, 2024

Is there a timeline or even a ballpark figure? I'm going to be free to start work on a learning management system (LMS) hopefully in August or September, and I'd like to work with cycle.js (as it matures).

I am not a CycleJS developer, so surely can't promise for them, but
from what I've read in the chat, they expect to roll out official 1.0 in July.
So, in my subjective opinion, it sounds possible. There are guys who already uses it in production so we can ask them for real-world examples, including AJAX, at least.

There're other blind spots like forms, but I expect them to be of medium (possible) compexity.

from cyclejs-examples.

chasm avatar chasm commented on May 25, 2024

Excellent. I'll look for it. Thanks.

from cyclejs-examples.

jessep avatar jessep commented on May 25, 2024

Hi @chasm, disclaimer: I'm just learning cycle like you, so I have no idea what I'm talking about. But my instinct would be to just not depend on cycle directly for the ajax/server part at all.

If you are creating apps now, you have a method for authentication (which is really a server side issue, right? Client side you just need to store the cookie or token, and the server then decides whether to give you access to things you request) and one for polling or pushing data. So, just keep using whatever you do now, create an observable and push the results of the data you get from the server into it. Lets just say you are using something like firebase or socketio, that fires events when new data comes in. Just push that data into an observable that goes into your cycle system, no?

Or am I thinking about this in a totally naive way?

from cyclejs-examples.

chasm avatar chasm commented on May 25, 2024

@jessep, that's actually pretty much how I'm thinking about it -- at least until I think about how to make the back end equally reactive -- but like you I wonder if I'm just being naΓ―ve. New paradigms always take a while to sink in.

from cyclejs-examples.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.