-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #739 from pmcelhaney/rework-context
Rework context
- Loading branch information
Showing
10 changed files
with
465 additions
and
538 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"counterfact": minor | ||
--- | ||
|
||
minor breaking change: `$.context.ts` is now `_.context.ts` and exports a class named Context | ||
|
||
See https://github.com/pmcelhaney/counterfact/blob/main/docs/context-change.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Context Switch | ||
|
||
Version 0.36 has a minor breaking change in the way context objects are defined. | ||
|
||
## The file is now named `_.context.ts` instead of `$.context.ts`. | ||
|
||
This change was made because putting a `$` in a file name can be confusing in Mac/Linux/Unix systems. | ||
|
||
## Instead of exporting a default _value_, it the file should now export a class named `Context` | ||
|
||
### Old | ||
|
||
```ts | ||
class Context { | ||
// ... | ||
} | ||
|
||
export default new Context(); | ||
``` | ||
|
||
### New | ||
|
||
```ts | ||
export class Context { | ||
// ... | ||
} | ||
``` | ||
|
||
In the future, the context class will be able to have a constructor that takes one argument, an instance of the _parent_ context. | ||
|
||
```ts | ||
// paths/accounts/_context.ts | ||
import { CounterfactContext } from "../../types.ts"; | ||
|
||
export class Context extends CounterfactContext { | ||
constructor(registry) { | ||
this.mainContext = registry.find("/"); | ||
this.productsContext = registry.find("/products"); | ||
} | ||
// ... | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.