Skip to content

Commit

Permalink
feat!: add enableKopytkoComponentDidCatch bs_const
Browse files Browse the repository at this point in the history
  • Loading branch information
bchelkowski committed Feb 16, 2024
1 parent 8926608 commit 3b31ef8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .kopytkorc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"baseManifest": "./node_modules/@dazn/kopytko-unit-testing-framework/manifest.js",
"baseManifest": "./manifest.js",
"sourceDir": "./src",
"pluginDefinitions": {
"generate-tests": "./node_modules/@dazn/kopytko-unit-testing-framework/plugins/generate-tests"
Expand Down
3 changes: 3 additions & 0 deletions docs/renderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ these methods are called lifecycle methods:
```

- `componentDidCatch(error as Object, info as Object)` - called when a component method has thrown an error

IMPORTANT: This catch will only work with **bs_const** `enableKopytkoComponentDidCatch: true` in the **manifest** file.

```brightscript
sub componentDidCatch(error as Object, info as Object)
' The Roku exception object
Expand Down
18 changes: 14 additions & 4 deletions docs/versions-migration-guide.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
# Update Kopytko Framework to v2
# Update Kopytko Framework

## Highlighted breaking changes in Kopytko Framework v2
There were no interface changes making Kopytko Framework v2 a breaking change, but, because Kopytko Packager so far doesn't handle components and functions namespacing, the introduced new [`HttpRequest`](../src/components/http/request/Http.request.xml) component may cause name collision. It can happen if there already exist a HttpRequest component in the application the framework is used and it is very probable as Kopytko team was recommending creating own HttpRequest extending the [`Request`](../src/components/http/request/Request.xml) component. We came across Kopytko users' needs and created a helpful `HttpRequest` component implementing all necessary mechanisms to make an HTTP(S) call - we recommend switching over to Kopytko's `HttpRequest` component as soon as possible.
## Update from v2 to v3

Version 3 introduced the `componentDidCatch` lifecycle method. It is not needed to implement componentDidCatch, but there could be a scenario where it is implemented and a developer wants to disable it (for example, for the development time). Because of that there is a new **bs_const** that needs to be defined in the **manifest** file - `enableKopytkoComponentDidCatch`.

`enableKopytkoComponentDidCatch: true` - **enables** the `componentDidCatch` method

`enableKopytkoComponentDidCatch: false` - **disables** the `componentDidCatch` method

## Update from v1 to v2

### Highlighted breaking changes in Kopytko Framework v2

There were no interface changes making Kopytko Framework v2 a breaking change, but, because Kopytko Packager so far doesn't handle components and functions namespacing, the introduced new [`HttpRequest`](../src/components/http/request/Http.request.xml) component may cause name collision. It can happen if there already exist a HttpRequest component in the application the framework is used and it is very probable as Kopytko team was recommending creating own HttpRequest extending the [`Request`](../src/components/http/request/Request.xml) component. We came across Kopytko users' needs and created a helpful `HttpRequest` component implementing all necessary mechanisms to make an HTTP(S) call - we recommend switching over to Kopytko's `HttpRequest` component as soon as possible.

## Deprecations highlights in Kopytko Framework v2
### Deprecations highlights in Kopytko Framework v2

These APIs remain available in v2, but will be removed in future versions.

Expand Down
9 changes: 9 additions & 0 deletions manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const baseManifest = require('@dazn/kopytko-unit-testing-framework/manifest');

module.exports = {
...baseManifest,
bs_const: {
...baseManifest.bs_const,
enableKopytkoComponentDidCatch: false,
},
}
7 changes: 6 additions & 1 deletion src/components/renderer/Kopytko.brs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ sub init()
m.state = {}
m.elementToFocus = Invalid

m._enabledErrorCatching = Type(componentDidCatch) <> "<uninitialized>"
m._enabledErrorCatching = false
#if enableKopytkoComponentDidCatch
m._enabledErrorCatching = true
#end if
m._enabledErrorCatching = m._enabledErrorCatching AND Type(componentDidCatch) <> "<uninitialized>"

m._isInitialized = false
m._previousProps = {}
m._previousState = {}
Expand Down

0 comments on commit 3b31ef8

Please sign in to comment.