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
class Struct extends Map #321
Conversation
@@ -147,19 +147,20 @@ export default class Method extends Struct { | |||
} | |||
|
|||
get args (): Array<Base> { | |||
return (this.getAtIndex(1) as Struct<Base>).values(); | |||
// FIXME This should return a Struct instead of an Array | |||
return [...(this.get('args') as Struct).values()]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jacogr I think in the UI you use method.args()
as an array. So Map or Array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer array. Plus it is actually closer to .values()
@amaurymartiny dev PR merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
@@ -16,15 +16,15 @@ export class RxProposal extends Struct.with({ id: PropIndex, proposal: Proposal, | |||
} | |||
|
|||
get address (): AccountId { | |||
return this.raw.address as AccountId; | |||
return this.get('address') as AccountId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
I def prefer this - less magic.
// @ts-ignore FIXME | ||
value[jsonKey] | ||
); | ||
raw[key] = value[jsonKey as string] instanceof Types[key] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I really tried to fix that :)
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Related #161.
Instead of doing all types at once, let's do one by one, so that it's an easier transition. During this transition, I still added
this.raw = this;
in the Struct class.This is one of the bigger ones. Breaking changes:
Struct.keys()
returns an iterator, not an arrayStruct.values()
returns an iterator, not an arrayTODO: