Skip to content

Commit

Permalink
improved cache and routing systems
Browse files Browse the repository at this point in the history
  • Loading branch information
ortexx committed Jan 5, 2024
1 parent 2f96f9d commit c647266
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions dist/akili.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "akili",
"version": "1.2.32",
"version": "1.2.33",
"description": "Akili - javascript framework",
"main": "./src/akili.js",
"author": {
Expand Down
10 changes: 7 additions & 3 deletions src/akili.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,20 @@ Akili.unisolate = function (fn) {
* Initialize the element
*
* @param {Element} el
* @param {Element} root
* @param {object} [options={}]
* @returns {*}
*/
Akili.initialize = function (el, options = {}) {
Akili.initialize = function (el, root, options = {}) {
let recompile = options.recompile;
let component = el.__akili;

if (component) {
if (recompile) {
component.__recompile(recompile === true? {}: recompile);
const info = recompile === true? {}: recompile;
info.root = root;
info.initiator = root.__akili;
component.__recompile(info);
return component;
}

Expand Down Expand Up @@ -463,7 +467,7 @@ Akili.compile = function (root, options = { recompile: false }) {
}

const nestedInitializing = el => {
let component = this.initialize(el, options);
let component = this.initialize(el, root, options);
let children = el.children;
component && elements.push(component);

Expand Down
6 changes: 3 additions & 3 deletions src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ export default class Component {
});
}
}
else {
else if(!this.__compiling.route || this.parents('route')[0] === this.__compiling.route) {
res = Akili.isolate(() => {
this.attrs.onRecompiled && this.attrs.onRecompiled.trigger(undefined, { bubbles: false });
this.recompiled();
this.attrs.onRecompiled && this.attrs.onRecompiled.trigger(this.__compiling, { bubbles: false });
this.recompiled(this.__compiling);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class Route extends Component {
};

if (!load) {
return Akili.compile(this.el, { recompile: { checkChanges: true } });
return Akili.compile(this.el, { recompile: { checkChanges: true, route: this } });
}

return Promise.resolve().then(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/services/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class Request {

let hash = null;
let cache = typeof options.cache == 'function'? options.cache(options): options.cache;
(!window.AKILI_SSR && !Akili.__init) && (cache = true);
(!window.AKILI_SSR && Akili.__init === null) && (cache = true);

if(options.method.toUpperCase() == 'GET' && (!options.body || typeof options.body == 'string')) {
hash = this.createCacheHash({
Expand Down

0 comments on commit c647266

Please sign in to comment.