-
Notifications
You must be signed in to change notification settings - Fork 43
refactor(ama-mfe-ng-utils): simplify resize directive #3051
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
base: main
Are you sure you want to change the base?
Conversation
View your CI Pipeline Execution ↗ for commit 6b0457e.
☁️ Nx Cloud last updated this comment at |
LGTM |
packages/@ama-mfe/ng-utils/src/resize/resize.consumer.service.ts
Outdated
Show resolved
Hide resolved
nice work :) it simplifies a lot the things. ok for points 1 and 2. |
b163888
to
fca9ea4
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- remove unnecessary inputs - remove the notion of `channelId` - simplify style binding
fca9ea4
to
6b0457e
Compare
@mrednic-1A, @kpanot, @matthieu-crouzet please take another look. We've decided with @mrednic-1A to simplify it even more and remove completely the notion of 'who was resize message sent from'. We might introduce it later if necessary at the higher |
@@ -46,7 +44,7 @@ export class ResizeConsumerService implements MessageConsumer<ResizeMessage> { | |||
* Use the message paylod to compute a new height and emit it via the public signal | |||
* @param message message to consume | |||
*/ | |||
'1.0': (message: RoutedMessage<ResizeV1_0>) => this.newHeight.set({ height: message.payload.height, channelId: message.from }) | |||
'1.0': (message: RoutedMessage<ResizeV1_0>) => this.heightPxSignal.set(message.payload.height) |
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.
If I understand well, with this change we will then limit the application to a single scalable iframe per app without strange behavior.
Not sure we want to bring this limitation at this stage to simplify the code.
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.
Hey, yes, of course one day we might need a mechanism to support multiple apps visible at the same time (ex. resize and subroute navigation). It's just today's consumer/producer model doesn't support this, because they're not configurable and register via DI.
I'd say passing and appId
as a part of a data model every time is not the best way to do it ;) ex. if we have other app-specific messages?
We need something like, even though it is not probably the best way to do it:
consumer.configure({
from: ['appId']
})
// or make `.start()` configurable:
consumer.start({
from: ['appId']
})
I'd also argue that it is not up to ResizeDirectve
to configure the consumer, but to one who knows the appId
(iframe level?). I can go further and argue that ResizeDirective
shouldn't even exist just to do [style.height]
binding, but it should be done by the iframe wrapper (but I won't ;).
I can add configuration in a separate PR, or later if necessary, I just don't think resize directive should even know about appId
.
WDYT?
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.
Here, I made a picture ;)
Basically the same way as switching by message type
at the consumer manager level, we should also allow consumer instances to filter who the message is from

Maybe just adding from
to the BasicConsumer would do the job:
export interface BasicMessageConsumer<T extends Message = Message> {
type: T['type'];
from: string[];
supportedVersions: Record<string, MessageCallback<any>>;
}
or at the lower level (.start()
or .configure()
):
export interface MessageConsumer<T extends Message> extends BasicMessageConsumer {
type: T['type'];
supportedVersions: {
[V in T['version']]: MessageCallback<T & { version: V }>;
};
configure(config);
start(config): void;
stop(): void;
}
Proposed change
This is for discussion first, I haven't modified tests yet.
Simplify resize directive and message consumer. Three changes:
[style.height.px]
simplifies things greatlyconnectId
is handled at the consumer level, not at the directive level. Also I don't see the point in providing it in root as it is tightly coupled withconnectId
and directive instance.[connect]
and[scalable]
inputs? Can we just removescalable
input and use connect? I don't really see the point in specifying BOTH.WDYT?