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

[BUG] IoEventContextToken is not exported #503

Closed
daweedm opened this issue Mar 15, 2023 · 3 comments · Fixed by #504
Closed

[BUG] IoEventContextToken is not exported #503

daweedm opened this issue Mar 15, 2023 · 3 comments · Fixed by #504

Comments

@daweedm
Copy link

daweedm commented Mar 15, 2023

Describe the bug

IoEventContextToken is not exported in the public API.

TS2305: Module '"ng-dynamic-component"' has no exported member 'IoEventContextToken'.

The following does not work :

import {IoEventContextToken} from "ng-dynamic-component";

Editor's import autocomplete generate the following instead :

import {IoEventContextToken} from "ng-dynamic-component/lib/io/event-context";

which produces the following error

 Error: Module not found: Error: Package path ./lib/io/event-context is not exported from package /usr/src/app/node_modules/ng-dynamic-component (see exports field in /usr/src/app/node_modules/ng-dynamic-component/package.json)

Expected behavior
IoEventContextToken should be available from the public API and should be able to be imported like this :

import {IoEventContextToken} from "ng-dynamic-component";

Reproduction
N/A

Environment:

  • OS: Debian 12
  • Browser: chrome
  • Library version: 10.6.1
  • Angular version: 15.1.0

Additional context
N/A

@daweedm daweedm added the bug label Mar 15, 2023
@daweedm
Copy link
Author

daweedm commented Mar 15, 2023

@gund I found a workaround by using .bind(this) directly in the template :

<ng-template
    [ngComponentOutlet]="PointingScreenItemComponent"
    [ndcDynamicInputs]="{item: item}"
    [ndcDynamicOutputs]="{selected: onItemSelected.bind(this)}"
    *ngFor="let item of items"></ng-template>

Since function context binding works in the template, isn't IoEventContextToken redundant ?

@gund
Copy link
Owner

gund commented Mar 15, 2023

@daweedm the .bind() workaround for sure works but it's inefficient as this call will be performed every time your component's view is change-detected, so IoEventContextToken is meant to optimally do this for you.
As a more performant workaround you can use arrow function for an event handler method on your component so it's already bound by default.

But it's a good catch, the IoEventContextToken must be part of the public API.
I will create a fix for this soon.

gund added a commit that referenced this issue Mar 15, 2023
@gund gund closed this as completed in #504 Mar 15, 2023
github-actions bot pushed a commit that referenced this issue Mar 15, 2023
## [10.6.2](v10.6.1...v10.6.2) (2023-03-15)

### Bug Fixes

* **api:** export event context symbols ([c5bbaf6](c5bbaf6)), closes [#503](#503)
@github-actions
Copy link

🎉 This issue has been resolved in version 10.6.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants