Skip to content

Conversation

@megoth
Copy link
Contributor

@megoth megoth commented Jun 11, 2019

Trying out new conventions using Surplus

This library allows us to write markup with JSX and handles internal state.

I've split code into controllers, views, models, and services.

This PR is to showcase the changes I've done, should not be merged before a broader discussion.

@megoth megoth requested a review from Vinnl June 11, 2019 08:05
Copy link
Contributor

@Vinnl Vinnl left a comment

Choose a reason for hiding this comment

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

Overall I really like the direction this is going in! It's a clear improvement over what we have now, in my eyes. I've added some food for thought inline that we can discuss.

The one major point, which I'm guessing you're probably already expecting, concerns the addition of Surplus. While I generally like its concepts, it comes with clear longevity concerns, which means we should be prepared to fork and maintain it eventually - and I'm not sure whether we have the capacity to do that, and whether that'd be worth it.

Thus, I think the primary thing I'd like a stronger rationale for, is: why not go with e.g. React, especially considering that that would allow us to reuse and dogfood the SDK?

@@ -0,0 +1,3 @@
declare module 'marked' {
Copy link
Contributor

Choose a reason for hiding this comment

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

Where the DT definitions insufficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, there's a definition already, didn't see that - should make use of that instead.

@@ -0,0 +1,3 @@
declare module 'marked' {
Copy link
Contributor

Choose a reason for hiding this comment

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

Where the DT definitions insufficient?


declare module 'solid-ui' {
export type SolidUi = any
export type SolidUi = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This PR should make this file redundant: https://github.com/solid/solid-ui/pull/70

},
module: {
rules: [
{ test: /\.tsx$/, loader: 'surplus-loader!ts-loader' },
Copy link
Contributor

Choose a reason for hiding this comment

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

Babel can load TypeScript files too, so I don't think there's a need to introduce ts-loader here.

"jest": "^24.8.0",
"surplus-loader": "^0.5.0",
"ts-jest": "^24.0.2",
"ts-loader": "^6.0.2",
Copy link
Contributor

Choose a reason for hiding this comment

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

As said below, I think ts-loader shouldn't be necessary.

import { TrustedApplication } from './trustedApplications.models'
import { getStatementsToAdd, getStatementsToDelete } from './trustedApplications.service'

const { authn, ns, store } = solidUi
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it'd be good to move away from the SolidUI Singleton, insofar as possible, i.e. by limiting access to it to trustedApplications/trustedApplicationsPane, and have that pass the required data (e.g. the current session) as a parameter to other modules that need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm thinking along this lines as well, but didn't want to revolutionize the code base all at once =P Probably need a migration path for this, but could of course introduce that in these conventions

}))
}

static createNew (_subject: NamedNode): TrustedApplication {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering whether a Factory might be overengineering this. As an alternative, we could also just define an interface using something like this:

export interface TrustedApplication {
    origin: DataSignal<string>
    subect: DataSignal<string>
    modes: Mode[]
}

export const fromSubject: (subject: NamedNode) => TrustedApplication = /* ... */
export const fromNamedNodes (subject: NamedNode, origin: NamedNode | null, modes: NamedNode[]) => TrustedApplication = /* ... */

Then no private constructor is needed, nor copy (which would just be const copiedApp = {...originalApp}), and a simple object would suffice.

const { S } = Surplus
const { widgets } = solidUi

export const TrustedApplicationsView = (controller: TrustedApplicationsController) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not directly clear to me that the separation of the view and the controller offers much value here - they seem pretty tightly coupled, with the controller's methods being closely related to what the view is doing. Would it not be more readable to have that logic co-located with the view that is influenced by it?

Rebased revamp on master
@megoth
Copy link
Contributor Author

megoth commented Jun 14, 2019

This relates to #72

@megoth
Copy link
Contributor Author

megoth commented Jun 22, 2019

We've decided to use React for this purpose going forward.

@megoth megoth closed this Jun 22, 2019
@timea-solid timea-solid deleted the soc-surplus branch February 28, 2022 17:07
@timea-solid timea-solid restored the soc-surplus branch February 28, 2022 17:07
@timea-solid timea-solid deleted the soc-surplus branch March 11, 2022 13:33
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.

3 participants