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

feat: add operator node, source node, and watcher node in core module #228

Merged
merged 11 commits into from
Jun 23, 2024

Conversation

stone-lyl
Copy link
Collaborator

@stone-lyl stone-lyl commented Jun 21, 2024

  • feat: add console node (watcher) and test
  • feat: add signal node (source) and test
  • feat: add sleep node (operator) and test
  • feat: add link node (operator)

todo:

  • added testing for the link node
  • links can be configured with an array of "Middleware"
  • a linkCount node has been introduced and tested
  • implement method to compose diagram elements and links
  • composed a diagram using the source node, watcher node, and operator node
  • add filter element and test
  • add merge element and test
    image
  • see demo 3 in dir V2/old.
  • add ability to create loops
  • convert diagram JSON to diagram
  • The diagram has been executed successfully.

Copy link

vercel bot commented Jun 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
data-story-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 21, 2024 3:48pm

Copy link
Owner

@ajthinking ajthinking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting stuff!! 🧠

@@ -0,0 +1,41 @@
import { Observable, Subscription, SubscriptionLike } from 'rxjs';

export interface INodePorts {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the best programmers I know scolded me big time for using I/Interface in identifiers 😄 we cant do it! https://stackoverflow.com/questions/68503504/what-is-the-naming-convention-for-interfaces-and-classes-in-typescript

@@ -0,0 +1,41 @@
import { Observable, Subscription, SubscriptionLike } from 'rxjs';

export interface INodePorts {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where useful, please provide a little doc bloc with the purpose of interface/type

nodeType: 'operator';
}

export type WatcherEvents = 'completed' | 'errored';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be singular: "WatcherEvent" ?

import { tap } from 'rxjs/operators';
import { firstValueFrom, ReplaySubject, Subscription, SubscriptionLike, Observer, Observable } from 'rxjs';

export class WatcherResult implements IWatcherResult, Observer<any> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, WatcherNode etc can be upgraded to its own file/colocate with a "WatcherNode" file?

getPort(portName: string): Observable<unknown>;
}

export interface ISourceNode {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, "Node" name is kind of already taken by the Diagram data structure.
We do have the Source/Operator/Watcher prefix here which is good.
As I understand it, now links will generate a operator node so we can handle counts, etc. Then, is it really a "Node" we are refering to?
We could consider a new name. Alternatively accept different "Node" concepts lives in three domains; ReactFlow, Diagram, Execution.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your suggestion is fantastic!
I believe renaming it to element might be a better choice.

import { Console } from './console';
import { take } from 'rxjs/operators';

describe('Console', () => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • We could consider instances/variables as lowercase always
  • Historically, I just gave the ComputerConfigs capitalization based on their "importance" / central nature. But not sure that is a clean idea
  • Files should always match case of primary export.

WDYT? Lets get a convention here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I agree with that point!
  2. Except for React Components, the rest could follow the first advice.
  3. The JS file name is part of the module identifier, so I believe it should adhere to a uniform standard rather than changing according to the content inside the file.
    Maybe we can refer to Google's JS guide, what do you think? https://google.github.io/styleguide/jsguide.html#file-name

events = new ReplaySubject<WatcherEvents>();
subscription = new Subscription();

public complete() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer no public as it is default?

@ajthinking ajthinking merged commit 1a8398d into ajthinking:main Jun 23, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants